forked from neo-project/neo-devpack-dotnet
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Framework Add] predefine manifest (neo-project#903)
* predefine manifest * one attribute per file * remove empty line * Update tests/Neo.SmartContract.Framework.UnitTests/ManifestAttributeTest.cs * Update src/Neo.SmartContract.Framework/Attributes/ManifestExtraAttribute.cs * Update src/Neo.SmartContract.Framework/Attributes/ManifestExtraAttribute.cs * Update src/Neo.Compiler.CSharp/CompilationContext.cs --------- Co-authored-by: Shargon <[email protected]>
- Loading branch information
1 parent
f386442
commit 5536107
Showing
8 changed files
with
124 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Neo.SmartContract.Framework/Attributes/AuthorAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Neo.SmartContract.Framework.Attributes | ||
{ | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class AuthorAttribute : ManifestExtraAttribute | ||
{ | ||
public AuthorAttribute(string value) : base(AttributeType[nameof(AuthorAttribute)], value) | ||
{ | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Neo.SmartContract.Framework/Attributes/DescriptionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Neo.SmartContract.Framework.Attributes | ||
{ | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class DescriptionAttribute : ManifestExtraAttribute | ||
{ | ||
public DescriptionAttribute(string value) : base(AttributeType[nameof(DescriptionAttribute)], value) | ||
{ | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Neo.SmartContract.Framework/Attributes/EmailAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Neo.SmartContract.Framework.Attributes | ||
{ | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class EmailAttribute : ManifestExtraAttribute | ||
{ | ||
public EmailAttribute(string value) : base(AttributeType[nameof(EmailAttribute)], value) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Neo.SmartContract.Framework/Attributes/VersionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace Neo.SmartContract.Framework.Attributes | ||
{ | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class VersionAttribute : ManifestExtraAttribute | ||
{ | ||
public VersionAttribute(string value) : base(AttributeType[nameof(VersionAttribute)], value) | ||
{ | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/Neo.SmartContract.Framework.TestContracts/Contract_ManifestAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Neo.SmartContract.Framework.Attributes; | ||
|
||
namespace Neo.SmartContract.Framework.UnitTests.TestClasses | ||
{ | ||
[Author("core-dev")] | ||
[Email("[email protected]")] | ||
[Version("v3.6.3")] | ||
[Description("This is a test contract.")] | ||
[ManifestExtra("ExtraKey", "ExtraValue")] | ||
public class Contract_ManifestAttribute : SmartContract | ||
{ | ||
[NoReentrant] | ||
public void reentrantTest(int value) | ||
{ | ||
if (value == 0) return; | ||
if (value == 123) | ||
{ | ||
reentrantTest(0); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Neo.SmartContract.Framework.UnitTests/ManifestAttributeTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Neo.SmartContract.Framework.UnitTests; | ||
|
||
[TestClass] | ||
public class ManifestAttributeTest | ||
{ | ||
[TestMethod] | ||
public void TestManifestAttribute() | ||
{ | ||
var testEngine = new TestEngine.TestEngine(); | ||
testEngine.AddEntryScript(Utils.Extensions.TestContractRoot + "Contract_ManifestAttribute.cs"); | ||
|
||
var extra = testEngine.Manifest!.Extra; | ||
|
||
Assert.AreEqual(5, extra.Count); | ||
// [Author("core-dev")] | ||
// [Email("[email protected]")] | ||
// [Version("v3.6.3")] | ||
// [Description("This is a test contract.")] | ||
// [ManifestExtra("ExtraKey", "ExtraValue")] | ||
Assert.AreEqual("core-dev", extra["Author"]!.GetString()); | ||
Assert.AreEqual("[email protected]", extra["E-mail"]!.GetString()); | ||
Assert.AreEqual("v3.6.3", extra["Version"]!.GetString()); | ||
Assert.AreEqual("This is a test contract.", extra["Description"]!.GetString()); | ||
Assert.AreEqual("ExtraValue", extra["ExtraKey"]!.GetString()); | ||
} | ||
} |