Skip to content

Commit

Permalink
3.4.0 (#761)
Browse files Browse the repository at this point in the history
* update

* fix

* 3.4.0

* fix

Co-authored-by: Erik Zhang <[email protected]>
  • Loading branch information
Ashuaidehao and erikzhang authored Aug 5, 2022
1 parent 7e01c1c commit 4ebc146
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<Copyright>2015-2022 The Neo Project</Copyright>
<VersionPrefix>3.3.0</VersionPrefix>
<VersionPrefix>3.4.0</VersionPrefix>
<TargetFramework>net6.0</TargetFramework>
<Authors>The Neo Project</Authors>
</PropertyGroup>
Expand Down
38 changes: 19 additions & 19 deletions src/Neo.Compiler.CSharp/CompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Neo.Cryptography.ECC;
using Neo.IO.Json;
using Neo.Json;
using Neo.SmartContract;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -181,33 +181,33 @@ public static Compilation GetCompilation(string csproj, Options options, out XDo
WorkingDirectory = folder
})!.WaitForExit();
string assetsPath = Path.Combine(folder, "obj", "project.assets.json");
JObject assets = JObject.Parse(File.ReadAllBytes(assetsPath));
foreach (var (name, package) in assets["targets"][0].Properties)
JObject assets = (JObject)JToken.Parse(File.ReadAllBytes(assetsPath))!;
foreach (var (name, package) in ((JObject)assets["targets"]![0]!).Properties)
{
MetadataReference? reference = GetReference(name, package, assets, folder, options, compilationOptions);
MetadataReference? reference = GetReference(name, (JObject)package!, assets, folder, options, compilationOptions);
if (reference is not null) references.Add(reference);
}
IEnumerable<SyntaxTree> syntaxTrees = sourceFiles.OrderBy(p => p).Select(p => CSharpSyntaxTree.ParseText(File.ReadAllText(p), options: options.GetParseOptions(), path: p));
return CSharpCompilation.Create(assets["project"]["restore"]["projectName"].GetString(), syntaxTrees, references, compilationOptions);
return CSharpCompilation.Create(assets["project"]!["restore"]!["projectName"]!.GetString(), syntaxTrees, references, compilationOptions);
}

private static MetadataReference? GetReference(string name, JObject package, JObject assets, string folder, Options options, CSharpCompilationOptions compilationOptions)
{
string assemblyName = Path.GetDirectoryName(name)!;
if (!metaReferences.TryGetValue(assemblyName, out var reference))
{
switch (assets["libraries"][name]["type"].GetString())
switch (assets["libraries"]![name]!["type"]!.GetString())
{
case "package":
string packagesPath = assets["project"]["restore"]["packagesPath"].GetString();
string namePath = assets["libraries"][name]["path"].GetString();
string[] files = assets["libraries"][name]["files"].GetArray()
.Select(p => p.GetString())
string packagesPath = assets["project"]!["restore"]!["packagesPath"]!.GetString();
string namePath = assets["libraries"]![name]!["path"]!.GetString();
string[] files = ((JArray)assets["libraries"]![name]!["files"]!)
.Select(p => p!.GetString())
.Where(p => p.StartsWith("src/"))
.ToArray();
if (files.Length == 0)
{
JObject dllFiles = package["compile"] ?? package["runtime"];
JObject? dllFiles = (JObject?)(package["compile"] ?? package["runtime"]);
if (dllFiles is null) return null;
foreach (var (file, _) in dllFiles.Properties)
{
Expand All @@ -227,7 +227,7 @@ public static Compilation GetCompilation(string csproj, Options options, out XDo
}
break;
case "project":
string msbuildProject = assets["libraries"][name]["msbuildProject"].GetString();
string msbuildProject = assets["libraries"]![name]!["msbuildProject"]!.GetString();
msbuildProject = Path.GetFullPath(msbuildProject, folder);
reference = GetCompilation(msbuildProject, options, out _).ToMetadataReference();
break;
Expand Down Expand Up @@ -304,7 +304,7 @@ public JObject CreateManifest()
["name"] = ContractName,
["groups"] = new JArray(),
["features"] = new JObject(),
["supportedstandards"] = supportedStandards.OrderBy(p => p).Select(p => (JString)p).ToArray(),
["supportedstandards"] = supportedStandards.OrderBy(p => p).Select(p => (JString)p!).ToArray(),
["abi"] = new JObject
{
["methods"] = methodsExported.Select(p => new JObject
Expand Down Expand Up @@ -333,30 +333,30 @@ public JObject CreateDebugInformation()
return new JObject
{
["hash"] = Script.ToScriptHash().ToString(),
["documents"] = sourceLocations.Select(p => (JString)p).ToArray(),
["static-variables"] = staticFields.OrderBy(p => p.Value).Select(p => (JString)$"{p.Key.Name},{p.Key.Type.GetContractParameterType()},{p.Value}").ToArray(),
["documents"] = sourceLocations.Select(p => (JString)p!).ToArray(),
["static-variables"] = staticFields.OrderBy(p => p.Value).Select(p => ((JString)$"{p.Key.Name},{p.Key.Type.GetContractParameterType()},{p.Value}")!).ToArray(),
["methods"] = methodsConverted.Where(p => p.SyntaxNode is not null).Select(m => new JObject
{
["id"] = m.Symbol.ToString(),
["name"] = $"{m.Symbol.ContainingType},{m.Symbol.Name}",
["range"] = $"{m.Instructions[0].Offset}-{m.Instructions[^1].Offset}",
["params"] = (m.Symbol.IsStatic ? Array.Empty<string>() : new string[] { "this,Any" })
.Concat(m.Symbol.Parameters.Select(p => $"{p.Name},{p.Type.GetContractParameterType()}"))
.Select((p, i) => (JString)$"{p},{i}")
.Select((p, i) => ((JString)$"{p},{i}")!)
.ToArray(),
["return"] = m.Symbol.ReturnType.GetContractParameterType().ToString(),
["variables"] = m.Variables.Select(p => (JString)$"{p.Symbol.Name},{p.Symbol.Type.GetContractParameterType()},{p.SlotIndex}").ToArray(),
["variables"] = m.Variables.Select(p => ((JString)$"{p.Symbol.Name},{p.Symbol.Type.GetContractParameterType()},{p.SlotIndex}")!).ToArray(),
["sequence-points"] = m.Instructions.Where(p => p.SourceLocation is not null).Select(p =>
{
FileLinePositionSpan span = p.SourceLocation!.GetLineSpan();
return (JString)$"{p.Offset}[{Array.IndexOf(sourceLocations, p.SourceLocation.SourceTree!.FilePath)}]{span.StartLinePosition.Line + 1}:{span.StartLinePosition.Character + 1}-{span.EndLinePosition.Line + 1}:{span.EndLinePosition.Character + 1}";
return ((JString)$"{p.Offset}[{Array.IndexOf(sourceLocations, p.SourceLocation.SourceTree!.FilePath)}]{span.StartLinePosition.Line + 1}:{span.StartLinePosition.Character + 1}-{span.EndLinePosition.Line + 1}:{span.EndLinePosition.Character + 1}")!;
}).ToArray()
}).ToArray(),
["events"] = eventsExported.Select(e => new JObject
{
["id"] = e.Name,
["name"] = $"{e.Symbol.ContainingType},{e.Symbol.Name}",
["params"] = e.Parameters.Select((p, i) => (JString)$"{p.Name},{p.Type},{i}").ToArray()
["params"] = e.Parameters.Select((p, i) => ((JString)$"{p.Name},{p.Type},{i}")!).ToArray()
}).ToArray()
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/Neo.Compiler.CSharp/Neo.Compiler.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" />
<PackageReference Include="Neo" Version="3.3.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta3.22114.1" />
<PackageReference Include="Neo" Version="3.4.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Neo.Compiler.CSharp/PermissionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Redistribution and use in source and binary forms with or without
// modifications are permitted.

using Neo.IO.Json;
using Neo.Json;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -77,7 +77,7 @@ public JArray ToJson()
permissions.Add(new JObject
{
["contract"] = group.Key,
["methods"] = new JArray(group.OrderBy(p => p).Select(p => (JString)p))
["methods"] = new JArray(group.OrderBy(p => p).Select(p => (JString)p!))
});
foreach (string hash in wildcardHashes.OrderBy(p => p))
permissions.Add(new JObject
Expand All @@ -89,7 +89,7 @@ public JArray ToJson()
permissions.Add(new JObject
{
["contract"] = "*",
["methods"] = new JArray(wildcardMethods.OrderBy(p => p).Select(p => (JString)p))
["methods"] = new JArray(wildcardMethods.OrderBy(p => p).Select(p => (JString)p!))
});
}
return permissions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo.SmartContract.Framework" Version="3.3.0" />
<PackageReference Include="Neo.SmartContract.Framework" Version="3.4.0" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.CSharp.UnitTests/UnitTest_ABI_Event.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.CSharp.UnitTests.Utils;
using Neo.IO.Json;
using Neo.Json;
using System;

namespace Neo.Compiler.CSharp.UnitTests
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.CSharp.UnitTests/UnitTest_ABI_Safe.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.CSharp.UnitTests.Utils;
using Neo.IO.Json;
using Neo.Json;

namespace Neo.Compiler.CSharp.UnitTests
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.CSharp.UnitTests/UnitTest_DebugInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.CSharp.UnitTests.Utils;
using Neo.IO.Json;
using Neo.Json;
using Neo.SmartContract;
using System.Linq;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.CSharp.UnitTests.Utils;
using Neo.IO.Json;
using Neo.Json;

namespace Neo.Compiler.CSharp.UnitTests
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void TestABIOffsetWithoutOptimizer()
{
testEngine.Reset();
var abi = testEngine.Manifest["abi"];
var property = abi["methods"].GetArray()[0];
var property = abi["methods"][0];
Assert.AreEqual("symbol", property["name"].GetString());
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Types.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.CSharp.UnitTests.Utils;
using Neo.IO;
using Neo.IO.Json;
using Neo.Json;
using Neo.VM;
using Neo.VM.Types;
using Neo.Wallets;
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.CSharp.UnitTests/Utils/TestEngine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Neo.IO.Json;
using Neo.Json;
using Neo.Network.P2P.Payloads;
using Neo.Persistence;
using Neo.SmartContract;
Expand Down
6 changes: 3 additions & 3 deletions tests/Neo.SmartContract.Framework.UnitTests/ListTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.CSharp.UnitTests.Utils;
using Neo.IO.Json;
using Neo.Json;
using Neo.VM;
using Neo.VM.Types;

Expand Down Expand Up @@ -107,11 +107,11 @@ public void TestArrayConvert()
}
}

static JObject ParseJson(StackItem item)
static JToken ParseJson(StackItem item)
{
Assert.IsInstanceOfType(item, typeof(VM.Types.ByteString));
var json = System.Text.Encoding.UTF8.GetString(item.GetSpan());
return JObject.Parse(json);
return JToken.Parse(json);
}
}
}

0 comments on commit 4ebc146

Please sign in to comment.