Skip to content

Commit

Permalink
Convert to Neo.Json and Neo.ConsoleService to dotnet standard 2.1 (#…
Browse files Browse the repository at this point in the history
…3044)

* fixes #3038

* removed websocket port from configs

* Removed wsport from settings

* Converted neo.json to dotnet standard 2.1

* fix tests

* fix workflow

* added <IsPackable>false</IsPackable> to tests

* removed unused files

* Fixed TryGetValue

* converted Neo.ConsoleService to standard

* fixed warning

* fixes for dotnet

* fixed warning

* Fixed header

* Fixed settings and added in shargons request

* convert neto to standard

* fixed getBit size

* Fixed bitlen and Murmur128

* fixes

* contractask update

* Remove IsExternalInit

* Unify LangVersion

* Remove comments

* Remove more comments

* Revert main.yml

* Revert neo changes

* fix targetFramework

* revert revert main.yml

---------

Co-authored-by: Shargon <shargon@gmail.com>
  • Loading branch information
cschuchardt88 and shargon authored Jan 10, 2024
1 parent d98b0af commit cfffe4f
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 32 deletions.
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
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<PropertyGroup>
<Copyright>2015-2023 The Neo Project</Copyright>
<VersionPrefix>3.6.2</VersionPrefix>
<LangVersion>11.0</LangVersion>
<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 @@ -489,8 +489,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
1 change: 1 addition & 0 deletions src/Neo.ConsoleService/Neo.ConsoleService.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net7.0</TargetFrameworks>
<PackageId>Neo.ConsoleService</PackageId>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
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
5 changes: 5 additions & 0 deletions src/Neo.Json/Neo.Json.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageTags>NEO;JSON</PackageTags>
</PropertyGroup>

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

</Project>
4 changes: 4 additions & 0 deletions src/Neo.Json/OrderedDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public bool Remove(TKey key)
return collection.Remove(key);
}

#pragma warning disable CS8767

public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
{
if (collection.TryGetValue(key, out var entry))
Expand All @@ -101,6 +103,8 @@ public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
return false;
}

#pragma warning restore CS8767

void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
{
Add(item.Key, item.Value);
Expand Down
1 change: 0 additions & 1 deletion src/Neo.VM/Neo.VM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net7.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
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
2 changes: 2 additions & 0 deletions tests/Neo.Json.UnitTests/Neo.Json.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>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
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
1 change: 0 additions & 1 deletion tests/Neo.VM.Tests/Neo.VM.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<RootNamespace>Neo.Test</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
Expand Down

0 comments on commit cfffe4f

Please sign in to comment.