Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to Neo.Json and Neo.ConsoleService to dotnet standard 2.1 #3044

Merged
merged 45 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f980291
fixes #3038
cschuchardt88 Dec 28, 2023
e599745
removed websocket port from configs
cschuchardt88 Dec 29, 2023
22b7351
Removed wsport from settings
cschuchardt88 Dec 29, 2023
3fb628d
Merge branch 'master' into remove-websockets
shargon Dec 30, 2023
765accf
Converted neo.json to dotnet standard 2.1
cschuchardt88 Dec 30, 2023
1611fd8
fix tests
cschuchardt88 Dec 30, 2023
a6f059d
fix workflow
cschuchardt88 Dec 30, 2023
9bcd1b3
added <IsPackable>false</IsPackable> to tests
cschuchardt88 Dec 30, 2023
034a8a8
removed unused files
cschuchardt88 Dec 30, 2023
8f35694
Fixed TryGetValue
cschuchardt88 Dec 30, 2023
f968041
converted Neo.ConsoleService to standard
cschuchardt88 Dec 30, 2023
5eaf14d
fixed warning
cschuchardt88 Dec 30, 2023
c0b4831
fixes for dotnet
cschuchardt88 Dec 30, 2023
62159ea
fixed warning
cschuchardt88 Dec 30, 2023
eb09d41
Merge branch 'master' into standard/neo
cschuchardt88 Dec 31, 2023
3130075
Merge branch 'remove-websockets' into standard/neo
cschuchardt88 Jan 2, 2024
5d85114
Merge Master
cschuchardt88 Jan 2, 2024
9a55d88
Merge branch 'master' into standard/neo
cschuchardt88 Jan 4, 2024
5a43f2a
Merge branch 'standard/neo' of /~https://github.com/cschuchardt88/neo i…
cschuchardt88 Jan 4, 2024
59960f9
Fixed header
cschuchardt88 Jan 4, 2024
d0ae322
Merge branch 'master' into standard/neo
cschuchardt88 Jan 4, 2024
0c74a7c
Fixed settings and added in shargons request
cschuchardt88 Jan 4, 2024
687cfa8
Merge branch 'master' into standard/neo
cschuchardt88 Jan 5, 2024
7110220
Merge branch 'master' into standard/neo
cschuchardt88 Jan 6, 2024
032e6ee
Merge branch 'master' into standard/neo
cschuchardt88 Jan 9, 2024
d860c74
Merge branch 'master' into standard/neo
cschuchardt88 Jan 9, 2024
4dfda92
convert neto to standard
cschuchardt88 Jan 9, 2024
d1f4246
fixed getBit size
cschuchardt88 Jan 9, 2024
18da0e9
Fixed bitlen and Murmur128
cschuchardt88 Jan 9, 2024
17815e9
fixes
cschuchardt88 Jan 9, 2024
5873845
contractask update
cschuchardt88 Jan 9, 2024
2a08452
Merge branch 'master' into standard/neo
cschuchardt88 Jan 10, 2024
582c664
Merge branch 'master' into standard/neo
cschuchardt88 Jan 10, 2024
f1af082
Merge branch 'master' into standard/neo
cschuchardt88 Jan 10, 2024
592fa22
Merge branch 'standard/neo' of /~https://github.com/cschuchardt88/neo i…
shargon Jan 10, 2024
7d39a42
Merge branch 'master' into standard/neo
shargon Jan 10, 2024
e062760
Merge branch 'standard/neo' of /~https://github.com/cschuchardt88/neo i…
shargon Jan 10, 2024
de5a188
Remove IsExternalInit
shargon Jan 10, 2024
3f20896
Unify LangVersion
shargon Jan 10, 2024
0d87aa5
Remove comments
shargon Jan 10, 2024
99b645d
Remove more comments
shargon Jan 10, 2024
f0ca808
Revert main.yml
shargon Jan 10, 2024
d8c0a79
Revert neo changes
shargon Jan 10, 2024
6971700
fix targetFramework
shargon Jan 10, 2024
99bd317
revert revert main.yml
shargon Jan 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.net7.0.info

# MyGet isn't working
# PublishMyGet:
Expand Down
1 change: 0 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<Copyright>2015-2023 The Neo Project</Copyright>
<VersionPrefix>3.6.2</VersionPrefix>
<Authors>The Neo Project</Authors>
<TargetFrameworks>net7.0</TargetFrameworks>
<PackageIcon>neo.png</PackageIcon>
<PackageProjectUrl>/~https://github.com/neo-project/neo</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
1 change: 1 addition & 0 deletions src/Neo.CLI/Neo.CLI.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<AssemblyTitle>Neo.CLI</AssemblyTitle>
<AssemblyName>neo-cli</AssemblyName>
<OutputType>Exe</OutputType>
Expand Down
42 changes: 21 additions & 21 deletions src/Neo.CLI/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public static Settings Default

public Settings(IConfigurationSection section)
{
this.Logger = new(section.GetSection("Logger"));
this.Storage = new(section.GetSection("Storage"));
this.P2P = new(section.GetSection("P2P"));
this.UnlockWallet = new(section.GetSection("UnlockWallet"));
Logger = new(section.GetSection(nameof(Logger)));
Storage = new(section.GetSection(nameof(Storage)));
P2P = new(section.GetSection(nameof(P2P)));
UnlockWallet = new(section.GetSection(nameof(UnlockWallet)));
}
}

Expand All @@ -66,21 +66,21 @@ public class LoggerSettings

public LoggerSettings(IConfigurationSection section)
{
this.Path = section.GetValue("Path", "Logs")!;
this.ConsoleOutput = section.GetValue("ConsoleOutput", false);
this.Active = section.GetValue("Active", false);
Path = section.GetValue(nameof(Path), "Logs")!;
ConsoleOutput = section.GetValue(nameof(ConsoleOutput), false);
Active = section.GetValue(nameof(Active), false);
}
}

public class StorageSettings
{
public string Engine { get; }
public string Path { get; }
public string Engine { get; } = string.Empty;
public string Path { get; } = string.Empty;

public StorageSettings(IConfigurationSection section)
{
this.Engine = section.GetValue("Engine", "LevelDBStore")!;
this.Path = section.GetValue("Path", "Data_LevelDB_{0}")!;
Engine = section.GetValue(nameof(Engine), "LevelDBStore")!;
Path = section.GetValue(nameof(Path), "Data_LevelDB_{0}")!;
}
}

Expand All @@ -93,26 +93,26 @@ public class P2PSettings

public P2PSettings(IConfigurationSection section)
{
this.Port = section.GetValue<ushort>("Port", 10333);
this.MinDesiredConnections = section.GetValue("MinDesiredConnections", Peer.DefaultMinDesiredConnections);
this.MaxConnections = section.GetValue("MaxConnections", Peer.DefaultMaxConnections);
this.MaxConnectionsPerAddress = section.GetValue("MaxConnectionsPerAddress", 3);
Port = section.GetValue<ushort>(nameof(Port), 10333);
MinDesiredConnections = section.GetValue(nameof(MinDesiredConnections), Peer.DefaultMinDesiredConnections);
MaxConnections = section.GetValue(nameof(MaxConnections), Peer.DefaultMaxConnections);
MaxConnectionsPerAddress = section.GetValue(nameof(MaxConnectionsPerAddress), 3);
}
}

public class UnlockWalletSettings
{
public string? Path { get; }
public string? Password { get; }
public bool IsActive { get; }
public string Path { get; } = string.Empty;
public string Password { get; } = string.Empty;
public bool IsActive { get; } = false;

public UnlockWalletSettings(IConfigurationSection section)
{
if (section.Exists())
{
this.Path = section.GetValue("Path", "");
this.Password = section.GetValue("Password", "");
this.IsActive = bool.Parse(section.GetValue("IsActive", "false")!);
Path = section.GetValue(nameof(Path), string.Empty)!;
Password = section.GetValue(nameof(Password), string.Empty)!;
IsActive = section.GetValue(nameof(IsActive), false);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Neo.ConsoleService/ConsoleServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,10 @@ public void Run(string[] args)
}
else
{
Debug.Assert(OperatingSystem.IsWindows());
Debug.Assert(Environment.OSVersion.Platform == PlatformID.Win32NT);
#pragma warning disable CA1416
ServiceBase.Run(new ServiceProxy(this));
#pragma warning restore CA1416
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Neo.ConsoleService/Neo.ConsoleService.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net7.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<PackageId>Neo.ConsoleService</PackageId>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/Neo.ConsoleService/System/IsExternalInit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// IsExternalInit.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

namespace System.Runtime.CompilerServices
{
internal static class IsExternalInit { }
}
2 changes: 1 addition & 1 deletion src/Neo.Json/JArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ internal override void Write(Utf8JsonWriter writer)
writer.WriteEndArray();
}

public override JArray Clone()
public override JToken Clone()
{
var cloned = new JArray();

Expand Down
2 changes: 1 addition & 1 deletion src/Neo.Json/JBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal override void Write(Utf8JsonWriter writer)
writer.WriteBooleanValue(Value);
}

public override JBoolean Clone()
public override JToken Clone()
{
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.Json/JNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internal override void Write(Utf8JsonWriter writer)
writer.WriteNumberValue(Value);
}

public override JNumber Clone()
public override JToken Clone()
{
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.Json/JObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal override void Write(Utf8JsonWriter writer)
/// Creates a copy of the current JSON object.
/// </summary>
/// <returns>A copy of the current JSON object.</returns>
public override JObject Clone()
public override JToken Clone()
{
var cloned = new JObject();

Expand Down
4 changes: 2 additions & 2 deletions src/Neo.Json/JString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override T AsEnum<T>(T defaultValue = default, bool ignoreCase = false)
public override T GetEnum<T>(bool ignoreCase = false)
{
T result = Enum.Parse<T>(Value, ignoreCase);
if (!Enum.IsDefined(result)) throw new InvalidCastException();
if (!Enum.IsDefined(typeof(T), result)) throw new InvalidCastException();
return result;
}

Expand All @@ -79,7 +79,7 @@ internal override void Write(Utf8JsonWriter writer)
writer.WriteStringValue(Value);
}

public override JString Clone()
public override JToken Clone()
{
return this;
}
Expand Down
24 changes: 15 additions & 9 deletions src/Neo.Json/Neo.Json.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageTags>NEO;JSON</PackageTags>
</PropertyGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net7.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.NET Standard 2.1 requires Lang 8.0, right?
And .NET 7.x C# 11?

is Lang 10 fine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use 11 in BLS and it works, we should use in all the same

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageTags>NEO;JSON</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this next Package?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it all different in netstandard

</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/Neo/Neo.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageTags>NEO;AntShares;Blockchain;Smart Contract</PackageTags>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<RootNamespace>neo_cli.Tests</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
32 changes: 17 additions & 15 deletions tests/Neo.Json.UnitTests/Neo.Json.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Neo.Json\Neo.Json.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Neo.Json\Neo.Json.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion tests/Neo.Json.UnitTests/UT_JObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void TestGetNull()
[TestMethod]
public void TestClone()
{
var bobClone = bob.Clone();
var bobClone = (JObject)bob.Clone();
bobClone.Should().NotBeSameAs(bob);
foreach (var key in bobClone.Properties.Keys)
{
Expand Down
2 changes: 2 additions & 0 deletions tests/Neo.UnitTests/Neo.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down