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

Update for Neo 3.4 #39

Merged
merged 3 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning">
<Version> 3.5.107</Version>
<Version> 3.5.109</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
</PropertyGroup>

<PropertyGroup>
<BlockchainToolkitLibraryVersion>3.4.8-preview</BlockchainToolkitLibraryVersion>
<BlockchainToolkitLibraryVersion>3.4.12</BlockchainToolkitLibraryVersion>
<!-- <BlockchainToolkitLibraryVersion>local</BlockchainToolkitLibraryVersion> -->
<BlockchainToolkitLibraryLocalPath>..\..\..\lib-bctk</BlockchainToolkitLibraryLocalPath>
<NeoVersion>3.3.1</NeoVersion>
<NeoVersion>3.4.0</NeoVersion>
<NeoMonorepoPath>..\..\..\..\official\3neo-monorepo</NeoMonorepoPath>

</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/build-tasks/ContractGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static string GenerateContractInterface(NeoManifest manifest, string cont
? Regex.Replace(manifest.Name, "^.*\\.", string.Empty)
: contractNameOverride;

if (!IsValidTypeName(contractName) || contractName.Contains('.'))
if (!IsValidTypeName(contractName) || contractName.Contains('.'))
{
throw new Exception($"\"{contractName}\" is not a valid C# type name");
}
Expand Down
2 changes: 1 addition & 1 deletion src/test-harness/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static Script CreateScript<T>(this DataCache snapshot, params Expression<
}

public static void EmitContractCall<T>(this ScriptBuilder builder, ApplicationEngine engine, Expression<Action<T>> expression)
where T : class
where T : class
=> EmitContractCall<T>(builder, engine.Snapshot, expression);

public static void EmitContractCall<T>(this ScriptBuilder builder, DataCache snapshot, Expression<Action<T>> expression)
Expand Down
4 changes: 2 additions & 2 deletions test/test-build-tasks/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public static ProjectCreator ImportNeoBuildTools(this ProjectCreator @this)
.Import(targetsPath);
}

public static ProjectCreator ReferenceNeo(this ProjectCreator @this, string version = "3.3.1")
public static ProjectCreator ReferenceNeo(this ProjectCreator @this, string version)
{
return @this.ItemPackageReference("Neo", version: version);
}

public static ProjectCreator ReferenceNeoScFx(this ProjectCreator @this, string version = "3.3.0")
public static ProjectCreator ReferenceNeoScFx(this ProjectCreator @this, string version)
{
return @this.ItemPackageReference("Neo.SmartContract.Framework", version: version);
}
Expand Down
22 changes: 12 additions & 10 deletions test/test-build-tasks/TestBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace build_tasks
{
public partial class TestBuild : MSBuildTestBase
{
const string CURRENT_NEO_VERSION = "3.4.0";

readonly ITestOutputHelper output;

public TestBuild(ITestOutputHelper output)
Expand Down Expand Up @@ -50,15 +52,15 @@ public class TestContract : TokenContract
void test_BuildContract(string source, string sourceName = "contract.cs")
{
using var testRootPath = new TestRootPath();
InstallNccs(testRootPath);
InstallNccs(testRootPath, CURRENT_NEO_VERSION);

var sourcePath = Path.Combine(testRootPath, sourceName);
File.WriteAllText(sourcePath, source);

var creator = CreateDotNetSixProject(testRootPath)
.Property("NeoContractName", "$(AssemblyName)")
.ImportNeoBuildTools()
.ItemPackageReference("Neo.SmartContract.Framework", version: "3.3.0")
.ReferenceNeoScFx(CURRENT_NEO_VERSION)
.AssertBuild(output);
}

Expand Down Expand Up @@ -90,7 +92,7 @@ void test_NeoContractGeneration(string testRootPath, string manifest, string con

var creator = CreateDotNetSixProject(testRootPath)
.ImportNeoBuildTools()
.ReferenceNeo()
.ReferenceNeo(CURRENT_NEO_VERSION)
.ItemInclude("NeoContractGeneration", "registrar", metadata: metadata)
.AssertBuild(output);

Expand All @@ -116,7 +118,7 @@ public void can_generate_contract_from_NeoContractReference_with_ContractNameOve

void test_NeoContractReference(string testRootPath, string source, string contractNameOverride = "")
{
InstallNccs(testRootPath);
InstallNccs(testRootPath, CURRENT_NEO_VERSION);

var srcDir = Path.Combine(testRootPath, "src");
if (!Directory.Exists(srcDir)) Directory.CreateDirectory(srcDir);
Expand All @@ -125,7 +127,7 @@ void test_NeoContractReference(string testRootPath, string source, string contra
var srcCreator = CreateDotNetSixProject(testRootPath, "src/registrar.csproj")
.Property("NeoContractName", "$(AssemblyName)")
.ImportNeoBuildTools()
.ReferenceNeoScFx()
.ReferenceNeoScFx(CURRENT_NEO_VERSION)
.Save();

var metadata = new Dictionary<string, string?>();
Expand All @@ -136,7 +138,7 @@ void test_NeoContractReference(string testRootPath, string source, string contra

var testCreator = CreateDotNetSixProject(testRootPath, "test/registrarTests.csproj")
.ImportNeoBuildTools()
.ReferenceNeo()
.ReferenceNeo(CURRENT_NEO_VERSION)
.ItemInclude("NeoContractReference", srcCreator.FullPath, metadata: metadata)
.AssertBuild(output);

Expand All @@ -145,17 +147,17 @@ void test_NeoContractReference(string testRootPath, string source, string contra
}

[Theory, CombinatorialData]
public void debug_info_generation([CombinatorialValues("Debug", "Release")]string config, bool generateDebugInfo)
public void debug_info_generation([CombinatorialValues("Debug", "Release")] string config, bool generateDebugInfo)
{
using var testRootPath = new TestRootPath();
InstallNccs(testRootPath);
InstallNccs(testRootPath, CURRENT_NEO_VERSION);

var source = TestFiles.GetString("registrar.source");
File.WriteAllText(Path.Combine(testRootPath, "contract.cs"), source);
var creator = CreateDotNetSixProject(testRootPath, "registrar.csproj")
.Property("NeoContractName", "$(AssemblyName)")
.ImportNeoBuildTools()
.ReferenceNeoScFx();
.ReferenceNeoScFx(CURRENT_NEO_VERSION);

if (!generateDebugInfo)
{
Expand All @@ -176,7 +178,7 @@ public static ProjectCreator CreateDotNetSixProject(string directory, string pro
targetFramework: "net6.0");
}

static void InstallNccs(string path, string version = "3.3.0")
static void InstallNccs(string path, string version)
{
var runner = new ProcessRunner();
runner.RunThrow("dotnet", "new tool-manifest", path);
Expand Down
4 changes: 2 additions & 2 deletions test/test-build-tasks/TestDotNetToolTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace build_tasks
{
public class TestDotNetToolTask : MSBuildTestBase
public class TestDotNetToolTask : MSBuildTestBase
{
class TestTask : DotNetToolTask
{
Expand All @@ -15,7 +15,7 @@ class TestTask : DotNetToolTask

readonly Func<NugetPackageVersion, bool>? validator;

public TestTask(IProcessRunner processRunner, Func<NugetPackageVersion, bool> ?validator = null) : base(processRunner)
public TestTask(IProcessRunner processRunner, Func<NugetPackageVersion, bool>? validator = null) : base(processRunner)
{
this.validator = validator;
}
Expand Down
18 changes: 15 additions & 3 deletions test/test-build-tasks/test-build-tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,27 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="MSBuild.ProjectCreation" Version="8.2.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Xunit.Combinatorial" Version="1.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<!--
workaround for NuGet.Frameworks FileLoadException issue,
see https://github.com/dotnet/roslyn/issues/61454#issuecomment-1191209761
and https://github.com/jeffkl/MSBuildProjectCreator/issues/178
-->

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(MSBuildSDKsPath)\..\NuGet.Frameworks.dll"
DestinationFolder="$(OutputPath)"
ContinueOnError="false" />
</Target>

</Project>