Skip to content

Commit 2c8d94a

Browse files
committed
Merge branch 'master' into expression-comment
* master: [Framework Add] predefine manifest (neo-project#903) TestEngine: Get instruction coverage and move to net standard (neo-project#898) remove disable PublishToGithub (neo-project#901) Added `publish` to `github packages` and fix submodules (neo-project#899) bug: Fix default value when Stored (neo-project#895) Modify changelog during release (neo-project#900) Fixed `PackageReference` for `neo` (neo-project#897) cancel optimization on exception fix catch new Testing environment (neo-project#890) Updated submodule neo (neo-project#892) Update and fix Nep17 template (neo-project#891)
2 parents 4cd8139 + dfb1d3d commit 2c8d94a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4483
-102
lines changed

.github/workflows/main.yml

+15-33
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,6 @@ jobs:
5050
github-token: ${{ secrets.GITHUB_TOKEN }}
5151

5252
PublishGithub:
53-
# Because sometimes this action is not working as expected we will disable it until determine that it's more stable
54-
if: false && github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
55-
needs: Test
56-
runs-on: ubuntu-latest
57-
steps:
58-
- name: Checkout
59-
uses: actions/checkout@v4
60-
with:
61-
fetch-depth: 0
62-
- name: Setup .NET Core
63-
uses: actions/setup-dotnet@v4
64-
with:
65-
dotnet-version: ${{ env.DOTNET_VERSION }}
66-
- name: Setup NuGet.exe for use with actions
67-
uses: NuGet/setup-nuget@v1
68-
with:
69-
nuget-version: latest
70-
- name: Pack with dotnet
71-
run: git rev-list --count HEAD | xargs printf "CI%05d" | xargs dotnet pack src/Neo.SmartContract.Framework -c Debug -o out --include-source --version-suffix
72-
- name: Publish to Github Packages
73-
run: |
74-
nuget source Add -Name "GitHub" -Source "https://nuget.pkg.github.com/neo-project/index.json" -UserName neo-project -Password "${{ secrets.GITHUB_TOKEN }}"
75-
nuget push out/*.nupkg -Source "GitHub"
76-
77-
PublishMyGet:
7853
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
7954
needs: Test
8055
runs-on: ubuntu-latest
@@ -83,29 +58,35 @@ jobs:
8358
uses: actions/checkout@v4
8459
with:
8560
fetch-depth: 0
61+
submodules: recursive
8662
- name: Setup .NET Core
8763
uses: actions/setup-dotnet@v4
8864
with:
8965
dotnet-version: ${{ env.DOTNET_VERSION }}
66+
9067
- name: Set Version
9168
run: git rev-list --count HEAD | xargs printf 'CI%05d' | xargs -I{} echo 'VERSION_SUFFIX={}' >> $GITHUB_ENV
92-
- name: Pack Package(s)
69+
70+
- name : Pack (Neo.SmartContract.Framework)
9371
run: |
9472
dotnet pack ./src/Neo.SmartContract.Framework \
9573
--configuration Debug \
9674
--output ./out \
9775
--version-suffix ${{ env.VERSION_SUFFIX }}
98-
- name: Publish to MyGet
76+
- name : Pack (Neo.SmartContract.Testing)
77+
run: |
78+
dotnet pack ./src/Neo.SmartContract.Testing \
79+
--configuration Debug \
80+
--output ./out \
81+
--version-suffix ${{ env.VERSION_SUFFIX }}
82+
- name: Publish to Github Packages
9983
working-directory: ./out
10084
run: |
101-
for filename in *.nupkg; do
102-
dotnet nuget push "${filename}" \
103-
--source https://www.myget.org/F/neo/api/v3/index.json \
104-
--api-key "${{ secrets.MYGET_TOKEN }}" \
85+
dotnet nuget push * \
86+
--source https://nuget.pkg.github.com/neo-project/index.json \
87+
--api-key "${{ secrets.GITHUB_TOKEN }}" \
10588
--disable-buffering \
10689
--no-service-endpoint;
107-
done;
108-
shell: bash
10990
11091
Release:
11192
if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/')
@@ -116,6 +97,7 @@ jobs:
11697
uses: actions/checkout@v4
11798
with:
11899
fetch-depth: 0
100+
submodules: recursive
119101
- name: Get version
120102
id: get_version
121103
run: |

.github/workflows/pkgs-delete.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Nuget Package Cleanup (github)
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run every day at 24:00
6+
7+
jobs:
8+
delete-pkgs:
9+
name: Delete Old Nuget Packages
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Delete Neo.SmartContract.Testing Package
14+
uses: actions/delete-package-versions@v4
15+
with:
16+
package-name: Neo.SmartContract.Testing
17+
package-type: nuget
18+
min-versions-to-keep: 3
19+
token: "${{ secrets.GITHUB_TOKEN }}"
20+
21+
- name: Delete Neo.SmartContract.Framework Package
22+
uses: actions/delete-package-versions@v4
23+
with:
24+
package-name: Neo.Neo.SmartContract.Framework
25+
package-type: nuget
26+
min-versions-to-keep: 3
27+
token: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/release.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
authors:
6+
- octocat
7+
categories:
8+
- title: Breaking Changes 🛠
9+
labels:
10+
- breaking-change
11+
- title: Exciting New Features 🎉
12+
labels:
13+
- enhancement
14+
- title: What's Changed
15+
labels:
16+
- "*"

NuGet.Config

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration>
33
<packageSources>
44
<clear />
5-
<add key="MyGet-neo" value="https://www.myget.org/F/neo/api/v3/index.json" />
5+
<add key="github" value="https://nuget.pkg.github.com/neo-project/index.json" />
66
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
77
</packageSources>
88
</configuration>

neo-devpack-dotnet.sln

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.28803.452
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.7.34003.232
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Framework", "src\Neo.SmartContract.Framework\Neo.SmartContract.Framework.csproj", "{C30B5859-D4B9-46E8-A797-6B0A1B49B590}"
66
EndProject
@@ -16,22 +16,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{79389FC0-C62
1616
EndProject
1717
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D5266066-0AFD-44D5-A83E-2F73668A63C8}"
1818
EndProject
19-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Compiler.CSharp.TestContracts", "tests\Neo.Compiler.CSharp.TestContracts\Neo.Compiler.CSharp.TestContracts.csproj", "{8D67DD5A-D683-481F-915E-98683EA38791}"
19+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Compiler.CSharp.TestContracts", "tests\Neo.Compiler.CSharp.TestContracts\Neo.Compiler.CSharp.TestContracts.csproj", "{8D67DD5A-D683-481F-915E-98683EA38791}"
2020
EndProject
21-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.SmartContract.Framework.TestContracts", "tests\Neo.SmartContract.Framework.TestContracts\Neo.SmartContract.Framework.TestContracts.csproj", "{A372F1D6-51FF-472C-9508-FDAF7E6FEB13}"
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Framework.TestContracts", "tests\Neo.SmartContract.Framework.TestContracts\Neo.SmartContract.Framework.TestContracts.csproj", "{A372F1D6-51FF-472C-9508-FDAF7E6FEB13}"
2222
EndProject
23-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.SmartContract.TestEngine", "tests\Neo.SmartContract.TestEngine\Neo.SmartContract.TestEngine.csproj", "{D0153204-6AEF-4D94-B0E1-8124C38C91D4}"
23+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.TestEngine", "tests\Neo.SmartContract.TestEngine\Neo.SmartContract.TestEngine.csproj", "{D0153204-6AEF-4D94-B0E1-8124C38C91D4}"
2424
EndProject
25-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo", "neo\src\Neo\Neo.csproj", "{73223FBD-C562-4FA0-9722-C7F1C382A9DE}"
25+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo", "neo\src\Neo\Neo.csproj", "{73223FBD-C562-4FA0-9722-C7F1C382A9DE}"
2626
EndProject
27-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Cryptography.BLS12_381", "neo\src\Neo.Cryptography.BLS12_381\Neo.Cryptography.BLS12_381.csproj", "{D541BCE9-65BC-475B-94E5-19B6BFFF2B8E}"
27+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Cryptography.BLS12_381", "neo\src\Neo.Cryptography.BLS12_381\Neo.Cryptography.BLS12_381.csproj", "{D541BCE9-65BC-475B-94E5-19B6BFFF2B8E}"
2828
EndProject
29-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{35A34EBD-F2BF-4D83-A096-D5F007B12732}"
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.Json", "neo\src\Neo.Json\Neo.Json.csproj", "{35A34EBD-F2BF-4D83-A096-D5F007B12732}"
3030
EndProject
31-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{D6D53889-5A10-46A4-BA66-E78B56EC1881}"
31+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.VM", "neo\src\Neo.VM\Neo.VM.csproj", "{D6D53889-5A10-46A4-BA66-E78B56EC1881}"
3232
EndProject
3333
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependency", "Dependency", "{49D5873D-7B38-48A5-B853-85146F032091}"
3434
EndProject
35+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Testing", "src\Neo.SmartContract.Testing\Neo.SmartContract.Testing.csproj", "{648DCE6F-A0BA-4032-951B-20CF5BBFD998}"
36+
EndProject
37+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Testing.UnitTests", "tests\Neo.SmartContract.Testing.UnitTests\Neo.SmartContract.Testing.UnitTests.csproj", "{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}"
38+
EndProject
3539
Global
3640
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3741
Debug|Any CPU = Debug|Any CPU
@@ -86,6 +90,14 @@ Global
8690
{D6D53889-5A10-46A4-BA66-E78B56EC1881}.Debug|Any CPU.Build.0 = Debug|Any CPU
8791
{D6D53889-5A10-46A4-BA66-E78B56EC1881}.Release|Any CPU.ActiveCfg = Release|Any CPU
8892
{D6D53889-5A10-46A4-BA66-E78B56EC1881}.Release|Any CPU.Build.0 = Release|Any CPU
93+
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94+
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Debug|Any CPU.Build.0 = Debug|Any CPU
95+
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Release|Any CPU.ActiveCfg = Release|Any CPU
96+
{648DCE6F-A0BA-4032-951B-20CF5BBFD998}.Release|Any CPU.Build.0 = Release|Any CPU
97+
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
98+
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
99+
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
100+
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C}.Release|Any CPU.Build.0 = Release|Any CPU
89101
EndGlobalSection
90102
GlobalSection(SolutionProperties) = preSolution
91103
HideSolutionNode = FALSE
@@ -101,8 +113,10 @@ Global
101113
{D0153204-6AEF-4D94-B0E1-8124C38C91D4} = {D5266066-0AFD-44D5-A83E-2F73668A63C8}
102114
{73223FBD-C562-4FA0-9722-C7F1C382A9DE} = {49D5873D-7B38-48A5-B853-85146F032091}
103115
{D541BCE9-65BC-475B-94E5-19B6BFFF2B8E} = {49D5873D-7B38-48A5-B853-85146F032091}
104-
{D6D53889-5A10-46A4-BA66-E78B56EC1881} = {49D5873D-7B38-48A5-B853-85146F032091}
105116
{35A34EBD-F2BF-4D83-A096-D5F007B12732} = {49D5873D-7B38-48A5-B853-85146F032091}
117+
{D6D53889-5A10-46A4-BA66-E78B56EC1881} = {49D5873D-7B38-48A5-B853-85146F032091}
118+
{648DCE6F-A0BA-4032-951B-20CF5BBFD998} = {79389FC0-C621-4CEA-AD2B-6074C32E7BCA}
119+
{B772B8A9-9362-4C6F-A6D3-2A4138439B2C} = {D5266066-0AFD-44D5-A83E-2F73668A63C8}
106120
EndGlobalSection
107121
GlobalSection(ExtensibilityGlobals) = postSolution
108122
SolutionGuid = {6DA935E1-C674-4364-B087-F1B511B79215}

src/Neo.Compiler.CSharp/CompilationContext.cs

+12-6
Original file line numberDiff line numberDiff line change
@@ -426,31 +426,37 @@ private void ProcessClass(SemanticModel model, INamedTypeSymbol symbol)
426426
bool isSmartContract = isPublic && !isAbstract && isContractType;
427427
if (isSmartContract)
428428
{
429-
if (scTypeFound) throw new CompilationException(DiagnosticId.MultiplyContracts, $"Only one smart contract is allowed.");
429+
if (scTypeFound) throw new CompilationException(DiagnosticId.MultiplyContracts, "Only one smart contract is allowed.");
430430
scTypeFound = true;
431431
foreach (var attribute in symbol.GetAttributesWithInherited())
432432
{
433+
if (attribute.AttributeClass!.IsSubclassOf(nameof(ManifestExtraAttribute)))
434+
{
435+
manifestExtra[ManifestExtraAttribute.AttributeType[attribute.AttributeClass!.Name]] = (string)attribute.ConstructorArguments[0].Value!;
436+
continue;
437+
}
438+
433439
switch (attribute.AttributeClass!.Name)
434440
{
435441
case nameof(DisplayNameAttribute):
436442
displayName = (string)attribute.ConstructorArguments[0].Value!;
437443
break;
438-
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ContractSourceCodeAttribute):
444+
case nameof(ContractSourceCodeAttribute):
439445
Source = (string)attribute.ConstructorArguments[0].Value!;
440446
break;
441-
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ManifestExtraAttribute):
447+
case nameof(ManifestExtraAttribute):
442448
manifestExtra[(string)attribute.ConstructorArguments[0].Value!] = (string)attribute.ConstructorArguments[1].Value!;
443449
break;
444-
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ContractPermissionAttribute):
450+
case nameof(ContractPermissionAttribute):
445451
permissions.Add((string)attribute.ConstructorArguments[0].Value!, attribute.ConstructorArguments[1].Values.Select(p => (string)p.Value!).ToArray());
446452
break;
447-
case nameof(scfx.Neo.SmartContract.Framework.Attributes.ContractTrustAttribute):
453+
case nameof(ContractTrustAttribute):
448454
string trust = (string)attribute.ConstructorArguments[0].Value!;
449455
if (!ValidateContractTrust(trust))
450456
throw new ArgumentException($"The value {trust} is not a valid one for ContractTrust");
451457
trusts.Add(trust);
452458
break;
453-
case nameof(scfx.Neo.SmartContract.Framework.Attributes.SupportedStandardsAttribute):
459+
case nameof(SupportedStandardsAttribute):
454460
supportedStandards.UnionWith(
455461
attribute.ConstructorArguments[0].Values
456462
.Select(p => p.Value)

src/Neo.Compiler.CSharp/MethodConvert/MethodConvert.cs

+42-9
Original file line numberDiff line numberDiff line change
@@ -574,21 +574,42 @@ private void ConvertStorageBackedProperty(IPropertySymbol property, AttributeDat
574574
Call(ApplicationEngine.System_Storage_Get);
575575
switch (property.Type.Name)
576576
{
577-
case "SByte":
578-
case "Short":
579-
case "Int32":
580-
case "Int64":
577+
case "byte":
578+
case "sbyte":
581579
case "Byte":
580+
case "SByte":
581+
582+
case "short":
583+
case "ushort":
584+
case "Int16":
582585
case "UInt16":
586+
587+
case "int":
588+
case "uint":
589+
case "Int32":
583590
case "UInt32":
591+
592+
case "long":
593+
case "ulong":
594+
case "Int64":
584595
case "UInt64":
585596
case "BigInteger":
586-
ChangeType(VM.Types.StackItemType.Integer);
597+
// Replace NULL with 0
598+
AddInstruction(OpCode.DUP);
599+
AddInstruction(OpCode.ISNULL);
600+
JumpTarget ifFalse = new();
601+
Jump(OpCode.JMPIFNOT_L, ifFalse);
602+
{
603+
AddInstruction(OpCode.DROP);
604+
AddInstruction(OpCode.PUSH0);
605+
}
606+
ifFalse.Instruction = AddInstruction(OpCode.NOP);
587607
break;
588608
case "String":
589609
case "ByteString":
590610
case "UInt160":
591611
case "UInt256":
612+
case "ECPoint":
592613
break;
593614
default:
594615
Call(NativeContract.StdLib.Hash, "deserialize", 1, true);
@@ -620,19 +641,31 @@ private void ConvertStorageBackedProperty(IPropertySymbol property, AttributeDat
620641
AccessSlot(OpCode.LDARG, 1);
621642
switch (property.Type.Name)
622643
{
623-
case "SByte":
624-
case "Short":
625-
case "Int32":
626-
case "Int64":
644+
case "byte":
645+
case "sbyte":
627646
case "Byte":
647+
case "SByte":
648+
649+
case "short":
650+
case "ushort":
651+
case "Int16":
628652
case "UInt16":
653+
654+
case "int":
655+
case "uint":
656+
case "Int32":
629657
case "UInt32":
658+
659+
case "long":
660+
case "ulong":
661+
case "Int64":
630662
case "UInt64":
631663
case "BigInteger":
632664
case "String":
633665
case "ByteString":
634666
case "UInt160":
635667
case "UInt256":
668+
case "ECPoint":
636669
break;
637670
default:
638671
Call(NativeContract.StdLib.Hash, "serialize", 1, true);

src/Neo.Compiler.CSharp/Neo.Compiler.CSharp.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<ItemGroup>
2020
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
2121
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
22-
<PackageReference Include="Neo" Version="3.6.2" />
2322
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
2423
</ItemGroup>
2524

@@ -28,6 +27,7 @@
2827
<ProjectReference Include="..\Neo.SmartContract.Framework\Neo.SmartContract.Framework.csproj">
2928
<Aliases>scfx</Aliases>
3029
</ProjectReference>
30+
<ProjectReference Include="..\Neo.SmartContract.Testing\Neo.SmartContract.Testing.csproj" />
3131
</ItemGroup>
3232

3333
</Project>

src/Neo.Compiler.CSharp/Optimizer/Strategies/Reachability.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,12 @@ public static BranchType CoverInstruction(int addr, Script script, Dictionary<in
277277
((catchAddr, finallyAddr), stackType) = stack.Peek();
278278
if (stackType != TryStack.TRY && stackType != TryStack.CATCH) throw new BadScriptException("No try stack on ENDTRY");
279279

280-
// Visit catchAddr because there may still be exceptions at runtime
281-
Stack<((int returnAddr, int finallyAddr), TryStack stackType)> newStack = new(stack);
282-
CoverInstruction(catchAddr, script, coveredMap, stack: newStack, throwed: true);
280+
if (stackType == TryStack.TRY)
281+
{
282+
// Visit catchAddr because there may still be exceptions at runtime
283+
Stack<((int returnAddr, int finallyAddr), TryStack stackType)> newStack = new(stack);
284+
CoverInstruction(catchAddr, script, coveredMap, stack: newStack, throwed: true);
285+
}
283286

284287
stack.Pop();
285288
int endPointer = addr + instruction.TokenI8;

src/Neo.Compiler.CSharp/Options.cs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Options
2222
public bool Checked { get; set; }
2323
public bool Debug { get; set; }
2424
public bool Assembly { get; set; }
25+
public bool NoArtifacts { get; set; }
2526
public bool NoOptimize { get; set; }
2627
public bool NoInline { get; set; }
2728
public byte AddressVersion { get; set; }

0 commit comments

Comments
 (0)