Skip to content

Commit

Permalink
Update dev-pack with last neo changes (#146)
Browse files Browse the repository at this point in the history
* Update references

* Update

* Clean file

* Update tests/Neo.SmartContract.Framework.UnitTests/Neo.SmartContract.Framework.UnitTests.csproj

Co-Authored-By: Erik Zhang <erik@neo.org>

* Update tests/Neo.Compiler.MSIL.UnitTests/Neo.Compiler.MSIL.UnitTests.csproj

Co-Authored-By: Erik Zhang <erik@neo.org>

* Update src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj

Co-Authored-By: Erik Zhang <erik@neo.org>

* Add Reference Counter

* Clean file

* Clean files

* Fix travis in order to know the error

* Update packages

* Update .travis.yml

* End changes

* dotnet-format

* Fix shift UT

* Update version

* Update framework

* Fix UT
  • Loading branch information
shargon authored Dec 9, 2019
1 parent d3d00e2 commit ed93668
Show file tree
Hide file tree
Showing 29 changed files with 135 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ os:

dist: bionic
mono: none
dotnet: 2.2.402
dotnet: 3.1.100

install:
- dotnet tool install -g dotnet-format
Expand Down
5 changes: 3 additions & 2 deletions src/Neo.Compiler.MSIL/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static Assembly Create(Compilation comp)

if (!result.Success)
{
throw new ArgumentException();
throw new ArgumentException(string.Join(Environment.NewLine, result.Diagnostics.Select(u => u.ToString())));
}

streamDll.Position = 0;
Expand Down Expand Up @@ -175,11 +175,12 @@ private static MetadataReference[] CreateReferences(params string[] references)
var refs = new List<MetadataReference>(new MetadataReference[]
{
MetadataReference.CreateFromFile(Path.Combine(coreDir, "mscorlib.dll")),
MetadataReference.CreateFromFile(Path.Combine(coreDir, "netstandard.dll")),
MetadataReference.CreateFromFile(Path.Combine(coreDir, "System.Runtime.dll")),
MetadataReference.CreateFromFile(Path.Combine(coreDir, "System.Runtime.Numerics.dll")),
MetadataReference.CreateFromFile(typeof(System.ComponentModel.DisplayNameAttribute).Assembly.Location),
MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
MetadataReference.CreateFromFile(typeof(Neo.SmartContract.Framework.SmartContract).Assembly.Location),
MetadataReference.CreateFromFile(typeof(SmartContract.Framework.SmartContract).Assembly.Location),
});
refs.AddRange(references.Select(u => MetadataReference.CreateFromFile(u)));
return refs.ToArray();
Expand Down
10 changes: 5 additions & 5 deletions src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<Copyright>2015-2019 The Neo Project</Copyright>
<AssemblyTitle>Neo.Compiler.MSIL</AssemblyTitle>
<Version>2.4.1</Version>
<Version>3.0.0-preview1</Version>
<Authors>The Neo Project</Authors>
<TargetFrameworks>netcoreapp2.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netstandard2.1</TargetFrameworks>
<OutputType>Exe</OutputType>
<AssemblyName>neon</AssemblyName>
<PackageId>Neo.Compiler.MSIL</PackageId>
Expand All @@ -22,10 +22,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="3.4.0" />
<PackageReference Include="Mono.Cecil" Version="0.11.1" />
<PackageReference Include="Neo" Version="3.0.0-CI00212" />
<PackageReference Include="Neo" Version="3.0.0-CI00822" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 3 additions & 10 deletions src/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Copyright>2016-2017 The Neo Project</Copyright>
<Copyright>2016-2019 The Neo Project</Copyright>
<AssemblyTitle>Neo.SmartContract.Framework</AssemblyTitle>
<Version>2.9.3</Version>
<Version>3.0.0-preview1</Version>
<Authors>The Neo Project</Authors>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>Neo.SmartContract.Framework</AssemblyName>
<PackageId>Neo.SmartContract.Framework</PackageId>
<PackageTags>NEO;AntShares;Blockchain;Smart Contract;VM</PackageTags>
<PackageProjectUrl>https://github.com/neo-project/neo-devpack-dotnet</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/neo-project/neo-devpack-dotnet.git</RepositoryUrl>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.6' ">1.6.0</NetStandardImplicitPackageVersion>
<Company>The Neo Project</Company>
<Description>Neo.SmartContract.Framework</Description>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard1.6|AnyCPU'">
<DefineConstants>RELEASE;NETSTANDARD1_6</DefineConstants>
<DebugType>none</DebugType>
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions templates/Template.CSharp/ProjectTemplate.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo.SmartContract.Framework" Version="2.9.3" />
<PackageReference Include="Neo.SmartContract.Framework" Version="3.0.0-preview1" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
Expand Down
4 changes: 2 additions & 2 deletions templates/Template.VB/ProjectTemplate.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<RootNamespace>$safeprojectname$</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo.SmartContract.Framework" Version="2.9.3" />
<PackageReference Include="Neo.SmartContract.Framework" Version="3.0.0-preview1" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Neo.Compiler.MSIL</RootNamespace>
</PropertyGroup>
Expand Down
12 changes: 4 additions & 8 deletions tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_shift.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Neo.Compiler.MSIL.TestClasses
{
class Contract_shift : SmartContract.Framework.SmartContract
Expand All @@ -13,10 +9,10 @@ public static object Main(string method, object[] args)
var v2 = v << -1;
var v3 = v >> 1;
var v4 = v >> -1;
Neo.SmartContract.Framework.Services.Neo.Runtime.Log((string)(object)v1);
Neo.SmartContract.Framework.Services.Neo.Runtime.Log((string)(object)v2);
Neo.SmartContract.Framework.Services.Neo.Runtime.Log((string)(object)v3);
Neo.SmartContract.Framework.Services.Neo.Runtime.Log((string)(object)v4);
SmartContract.Framework.Services.Neo.Runtime.Notify(v1);
SmartContract.Framework.Services.Neo.Runtime.Notify(v2);
SmartContract.Framework.Services.Neo.Runtime.Notify(v3);
SmartContract.Framework.Services.Neo.Runtime.Notify(v4);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Neo.Compiler.MSIL.TestClasses
{
class Contract_shift_bigint : SmartContract.Framework.SmartContract
Expand All @@ -13,7 +9,10 @@ public static object Main(string method, object[] args)
var v2 = v << -1;
var v3 = v >> 1;
var v4 = v >> -1;
Neo.SmartContract.Framework.Services.Neo.Runtime.Notify(v1, v2, v3, v4);
SmartContract.Framework.Services.Neo.Runtime.Notify(v1);
SmartContract.Framework.Services.Neo.Runtime.Notify(v2);
SmartContract.Framework.Services.Neo.Runtime.Notify(v3);
SmartContract.Framework.Services.Neo.Runtime.Notify(v4);
return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;
using Neo.VM.Types;
using System;

namespace Neo.Compiler.MSIL
Expand Down Expand Up @@ -62,6 +62,7 @@ public void Test_ByteArray_New()
var bequal = wantresult.Equals(result);
Assert.IsTrue(bequal);
}

[TestMethod]
public void Test_ByteArrayPick()
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Appcall.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
{
Expand All @@ -27,7 +27,6 @@ public void Test_Appcall()

var bequal = wantresult.Equals(result);
Assert.IsTrue(bequal);

}
}
}
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_AutoEntrypoint.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
{
Expand All @@ -27,8 +28,7 @@ public void Test_AutoEntry_private()
var testengine = new TestEngine();
testengine.AddEntryScript("./TestClasses/Contract_autoentrypoint.cs");
testengine.ScriptEntry.DumpNEF();
StackItem[] _params = new StackItem[] { "privateMethod", new StackItem[0] };
var result = testengine.ExecuteTestCase(_params);//new test method02
var result = testengine.ExecuteTestCaseStandard("privateMethod");//new test method02

bool hadFault = (testengine.State & VMState.FAULT) > 0;
Assert.AreEqual(0, result.Count);//because no methodname had found, it do not return anything.
Expand Down
13 changes: 6 additions & 7 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_NULL.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
Expand All @@ -27,7 +26,7 @@ public void IsNull()
var item = result.Pop();

Assert.IsInstanceOfType(item, typeof(Boolean));
Assert.IsTrue(item.GetBoolean());
Assert.IsTrue(item.ToBoolean());

// False

Expand All @@ -36,7 +35,7 @@ public void IsNull()
item = result.Pop();

Assert.IsInstanceOfType(item, typeof(Boolean));
Assert.IsFalse(item.GetBoolean());
Assert.IsFalse(item.ToBoolean());
}

[TestMethod]
Expand All @@ -49,7 +48,7 @@ public void EqualNull()
var item = result.Pop();

Assert.IsInstanceOfType(item, typeof(Boolean));
Assert.IsTrue(item.GetBoolean());
Assert.IsTrue(item.ToBoolean());

// False

Expand All @@ -58,7 +57,7 @@ public void EqualNull()
item = result.Pop();

Assert.IsInstanceOfType(item, typeof(Boolean));
Assert.IsFalse(item.GetBoolean());
Assert.IsFalse(item.ToBoolean());

// True

Expand All @@ -67,7 +66,7 @@ public void EqualNull()
item = result.Pop();

Assert.IsInstanceOfType(item, typeof(Boolean));
Assert.IsTrue(item.GetBoolean());
Assert.IsTrue(item.ToBoolean());

// False

Expand All @@ -76,7 +75,7 @@ public void EqualNull()
item = result.Pop();

Assert.IsInstanceOfType(item, typeof(Boolean));
Assert.IsFalse(item.GetBoolean());
Assert.IsFalse(item.ToBoolean());
}
}
}
23 changes: 20 additions & 3 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Shift.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;
using Neo.SmartContract;
using System;
using System.Collections.Generic;
using System.Numerics;

namespace Neo.Compiler.MSIL
{
Expand All @@ -10,19 +13,33 @@ public class UnitTest_Shift
[TestMethod]
public void Test_Shift()
{
var list = new List<BigInteger>();
var method = new EventHandler<NotifyEventArgs>((sender, e) => list.Add(((VM.Types.Integer)((VM.Types.Array)e.State)[0]).ToBigInteger()));
ApplicationEngine.Notify += method;

var testengine = new TestEngine();
testengine.AddEntryScript("./TestClasses/Contract_shift.cs");
testengine.ScriptEntry.DumpNEF();
var result = testengine.ExecuteTestCaseStandard("testfunc");
ApplicationEngine.Notify -= method;

CollectionAssert.AreEqual(new BigInteger[] { 16, 17179869184, 4, 0 }, list);
}

[TestMethod]
public void Test_Shift_BigInteger()
{
var list = new List<BigInteger>();
var method = new EventHandler<NotifyEventArgs>((sender, e) => list.Add(((VM.Types.Integer)((VM.Types.Array)e.State)[0]).ToBigInteger()));
ApplicationEngine.Notify += method;

var testengine = new TestEngine();
testengine.AddEntryScript("./TestClasses/Contract_shift_bigint.cs");
testengine.ScriptEntry.DumpNEF();
StackItem[] _params = new StackItem[] { "testfunc", new StackItem[0] };
var result = testengine.ExecuteTestCase(_params);
var result = testengine.ExecuteTestCaseStandard("testfunc");
ApplicationEngine.Notify -= method;

CollectionAssert.AreEqual(new BigInteger[] { 16, 4, 4, 16 }, list);
}
}
}
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/UnitTest_StaticVar.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Switch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class UnitTest_Switch
[TestMethod]
public void Test_SwitchLong()
{
RandomAccessStack<StackItem> result;
EvaluationStack result;
TestEngine testengine = new TestEngine();
testengine.AddEntryScript("./TestClasses/Contract_SwitchLong.cs");

Expand All @@ -36,7 +36,7 @@ public void Test_SwitchLong()
[TestMethod]
public void Test_SwitchLong_Release()
{
RandomAccessStack<StackItem> result;
EvaluationStack result;
TestEngine testengine = new TestEngine();
testengine.AddEntryScript("./TestClasses/Contract_SwitchLong.cs", true);

Expand All @@ -59,7 +59,7 @@ public void Test_SwitchLong_Release()
[TestMethod]
public void Test_Switch6()
{
RandomAccessStack<StackItem> result;
EvaluationStack result;
TestEngine testengine = new TestEngine();
testengine.AddEntryScript("./TestClasses/Contract_Switch6.cs");

Expand Down
6 changes: 3 additions & 3 deletions tests/Neo.Compiler.MSIL.UnitTests/Utils/TestDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public TestDataCache(TKey key, TValue value)
{
dic.Add(key, value);
}
public override void DeleteInternal(TKey key)
protected override void DeleteInternal(TKey key)
{
dic.Remove(key);
}
Expand All @@ -28,9 +28,9 @@ protected override void AddInternal(TKey key, TValue value)
dic.Add(key, value);
}

protected override IEnumerable<KeyValuePair<TKey, TValue>> FindInternal(byte[] key_prefix)
protected override IEnumerable<(TKey Key, TValue Value)> FindInternal(byte[] key_prefix)
{
return dic.ToList();
return dic.Select(u => (u.Key, u.Value));
}

protected override TValue GetInternal(TKey key)
Expand Down
Loading

0 comments on commit ed93668

Please sign in to comment.