Skip to content

Commit

Permalink
Net8 (#43)
Browse files Browse the repository at this point in the history
* ported to net8
  • Loading branch information
MithrilMan authored May 20, 2024
1 parent 69eb753 commit d300695
Show file tree
Hide file tree
Showing 87 changed files with 757 additions and 893 deletions.
67 changes: 50 additions & 17 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
[*]
end_of_line = crlf
indent_size = 3
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 3
dotnet_style_coalesce_expression = true:error
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_object_initializer = true:warning

[*.xml]
indent_style = space
Expand All @@ -11,14 +18,14 @@ indent_style = space
########## Naming Styles
##### Naming Rules
# name all constant fields using UPPERCASE
dotnet_naming_rule.constant_fields_should_be_upper_case.severity = error
dotnet_naming_rule.constant_fields_should_be_upper_case.severity = error
dotnet_naming_rule.constant_fields_should_be_upper_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_upper_case.style = upper_case_style
dotnet_naming_rule.constant_fields_should_be_upper_case.style = upper_case_style

# name all private fields using camelCase and underscore prefix
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = error
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = error
##### End Naming Rules

##### End Symbol Specifications
Expand Down Expand Up @@ -74,7 +81,7 @@ csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async : error
csharp_prefer_braces = when_multiline : error
csharp_prefer_braces = when_multiline:error
csharp_prefer_simple_default_expression = true : suggestion
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
Expand All @@ -90,20 +97,20 @@ csharp_space_between_parentheses = false

csharp_style_deconstructed_variable_declaration = true : suggestion
csharp_style_conditional_delegate_call = true : suggestion
csharp_style_expression_bodied_accessors = true : silent
csharp_style_expression_bodied_constructors = true : silent
csharp_style_expression_bodied_indexers = true : silent
csharp_style_expression_bodied_methods = true : silent
csharp_style_expression_bodied_operators = true : silent
csharp_style_expression_bodied_properties = true : silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_constructors = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_operators = true:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_inlined_variable_declaration = true : error
csharp_style_pattern_local_over_anonymous_function = true : suggestion
csharp_style_pattern_matching_over_as_with_null_check = true : error
csharp_style_pattern_matching_over_is_with_cast_check = true : error
csharp_style_throw_expression = true : silent
csharp_style_var_elsewhere = false : suggestion
csharp_style_var_for_built_in_types = false : suggestion
csharp_style_var_when_type_is_apparent = true : suggestion
csharp_style_var_elsewhere = false
csharp_style_var_for_built_in_types = false
csharp_style_var_when_type_is_apparent = true



Expand Down Expand Up @@ -137,7 +144,7 @@ dotnet_diagnostic.CA1001.severity = suggestion
dotnet_diagnostic.CA1028.severity = suggestion

# CA1062: Validate arguments of public methods
dotnet_diagnostic.CA1062.severity = silent
dotnet_diagnostic.CA1062.severity = suggestion

# CA1308: Normalize strings to uppercase
dotnet_diagnostic.CA1308.severity = silent
Expand All @@ -149,7 +156,7 @@ dotnet_diagnostic.VSTHRD200.severity = suggestion
dotnet_diagnostic.CA1812.severity = none

# CA1819: Properties should not return arrays
dotnet_diagnostic.CA1819.severity = suggestion
dotnet_diagnostic.CA1819.severity = silent

# CA1040: Avoid empty interfaces
dotnet_diagnostic.CA1040.severity = suggestion
Expand All @@ -171,4 +178,30 @@ dotnet_diagnostic.CS1587.severity = silent

# IDE0090: Use 'new(...)'
csharp_style_implicit_object_creation_when_type_is_apparent = true: warning
csharp_style_namespace_declarations=file_scoped:warning
csharp_style_namespace_declarations= file_scoped:warning
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent

# IDE0008: Use explicit type
dotnet_diagnostic.IDE0008.severity = silent

# IDE0290: Use primary constructor
dotnet_diagnostic.IDE0290.severity = silent

# CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1510.severity = warning

# CA2254: Template should be a static expression
dotnet_diagnostic.CA2254.severity = warning

# IDE0057: Use range operator
dotnet_diagnostic.IDE0057.severity = silent

# CA2012: Use ValueTasks correctly
dotnet_diagnostic.CA2012.severity = silent
2 changes: 1 addition & 1 deletion .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: dotnet Restore
run: dotnet restore -s "https://api.nuget.org/v3/index.json" -s "https://f.feedz.io/davidfowl/bedrockframework/nuget/index.json"
Expand Down
8 changes: 5 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project>
<PropertyGroup>
<Copyright>2020 Mithril Man.</Copyright>
<Copyright>2024 Mithril Man.</Copyright>

<VersionPrefix>0.3.0</VersionPrefix>

<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

Expand All @@ -21,8 +23,8 @@

<PublishRepositoryUrl>true</PublishRepositoryUrl>

<TargetFramework>net6.0</TargetFramework>
<LangVersion>10.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ public static class Extensions
{
internal static byte[] SafeSubarray(this byte[] array, int offset, int count)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
ArgumentNullException.ThrowIfNull(array);
if (offset < 0 || offset > array.Length)
throw new ArgumentOutOfRangeException("offset");
if (count < 0 || offset + count > array.Length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,11 @@ internal static BigInteger WeightedAverage<T>(this IEnumerable<T> source, Func<T

internal static IEnumerable<TResult> WeightedFilter<T, TResult>(this IList<T> source, double start, double end, Func<T, BigInteger> weightSelector, Func<T, BigInteger, TResult> resultSelector)
{
if (source == null) throw new ArgumentNullException(nameof(source));
ArgumentNullException.ThrowIfNull(source);
if (start < 0 || start > 1) throw new ArgumentOutOfRangeException(nameof(start));
if (end < start || start + end > 1) throw new ArgumentOutOfRangeException(nameof(end));
if (weightSelector == null) throw new ArgumentNullException(nameof(weightSelector));
if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector));
ArgumentNullException.ThrowIfNull(weightSelector);
ArgumentNullException.ThrowIfNull(resultSelector);
if (source.Count == 0 || start == end) yield break;
double amount = (double)source.Select(weightSelector).Sum();
BigInteger sum = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public override int GetHashCode()
/// </summary>
public static new NEO_UInt256 Parse(string s)
{
if (s == null)
throw new ArgumentNullException();
ArgumentNullException.ThrowIfNull(s);
if (s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
s = s.Substring(2);
if (s.Length != LENGTH * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public override int GetHashCode()
/// </summary>
public static new UInt160 Parse(string value)
{
if (value == null)
throw new ArgumentNullException(nameof(value));
ArgumentNullException.ThrowIfNull(value);
if (value.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
value = value.Substring(2);
if (value.Length != LENGTH * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="NBitcoin" Version="5.0.76" />
</ItemGroup>

Expand All @@ -23,4 +23,17 @@
<ProjectReference Include="..\..\src\MithrilShards.Core\MithrilShards.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.6.133" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions src/ConnectionTest/ConnectionTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@
<ProjectReference Include="..\MithrilShards.Logging.Serilog\MithrilShards.Logging.Serilog.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.6.133" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/MithrilShards.Chain.Bitcoin.Dev/BitcoinDevShard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace MithrilShards.Chain.Bitcoin.Dev;
/// </summary>
public class BitcoinDevShard : IMithrilShard
{
public ValueTask InitializeAsync(CancellationToken cancellationToken) => default;
public ValueTask StartAsync(CancellationToken cancellationToken) => default;
public ValueTask StopAsync(CancellationToken cancellationToken) => default;
public Task InitializeAsync(CancellationToken cancellationToken) => Task.CompletedTask;
public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,17 @@
<ProjectReference Include="..\MithrilShards.Dev.Controller\MithrilShards.Dev.Controller.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.6.133" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@ private bool TryReadChecksum(ref SequenceReader<byte> reader)

public void WriteMessage(INetworkMessage message, IBufferWriter<byte> output)
{
if (message is null)
{
throw new ArgumentNullException(nameof(message));
}
ArgumentNullException.ThrowIfNull(message);

string command = message.Command;
using (_logger.BeginScope("Serializing and sending '{Command}'", command))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@
<ItemGroup>
<ProjectReference Include="..\MithrilShards.Network.Bedrock\MithrilShards.Network.Bedrock.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.6.133" />
</ItemGroup>
</Project>
29 changes: 4 additions & 25 deletions src/MithrilShards.Chain.Bitcoin/BitcoinShard.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MithrilShards.Core.Shards;

namespace MithrilShards.Chain.Bitcoin;

public class BitcoinShard : IMithrilShard
{
private readonly ILogger<BitcoinShard> _logger;
private readonly BitcoinSettings _settings;
public Task InitializeAsync(CancellationToken cancellationToken) => Task.CompletedTask;

public BitcoinShard(ILogger<BitcoinShard> logger, IOptions<BitcoinSettings> settings)
{
_logger = logger;
_settings = settings?.Value ?? throw new ArgumentNullException(nameof(settings));
}
public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;

public ValueTask InitializeAsync(CancellationToken cancellationToken)
{
return default;
}

public ValueTask StartAsync(CancellationToken cancellationToken)
{
return default;
}

public ValueTask StopAsync(CancellationToken cancellationToken)
{
return default;
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ public class InvalidChainDefinitionException : Exception
public InvalidChainDefinitionException() { }
public InvalidChainDefinitionException(string message) : base(message) { }
public InvalidChainDefinitionException(string message, Exception inner) : base(message, inner) { }
protected InvalidChainDefinitionException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ public class BlockHeaderRepositoryException : Exception
public BlockHeaderRepositoryException() { }
public BlockHeaderRepositoryException(string message) : base(message) { }
public BlockHeaderRepositoryException(string message, Exception inner) : base(message, inner) { }
protected BlockHeaderRepositoryException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
Loading

0 comments on commit d300695

Please sign in to comment.