-
Notifications
You must be signed in to change notification settings - Fork 105
cancel unnecessary constructors #1185
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
Conversation
…to cancel-constructor # Conflicts: # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_Attribute.cs # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_ManifestAttribute.cs # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard26.cs # tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard27.cs
@@ -34,7 +34,7 @@ public class CompilationEngine(CompilationOptions options) | |||
internal CompilationOptions Options { get; private set; } = options; | |||
private static readonly MetadataReference[] CommonReferences; | |||
private static readonly Dictionary<string, MetadataReference> MetaReferences = []; | |||
private static readonly Regex s_pattern = new(@"^(Neo\.SmartContract\.Framework\.SmartContract|SmartContract\.Framework\.SmartContract|Framework\.SmartContract|SmartContract)$"); | |||
internal static readonly Regex s_pattern = new(@"^(Neo\.SmartContract\.Framework\.SmartContract|SmartContract\.Framework\.SmartContract|Framework\.SmartContract|SmartContract|Neo\.SmartContract\.Framework\.Nep17Token|Neo\.SmartContract\.Framework\.TokenContract|Neo.SmartContract.Framework.Nep11Token<.*>)$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should try to remove this regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hecate2 this is needed? it should check the hierarchy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static bool IsDerivedFromSmartContract(INamedTypeSymbol classSymbol, Regex pattern)
{
var baseType = classSymbol.BaseType;
while (baseType != null)
{
if (pattern.IsMatch(baseType.ToString() ?? string.Empty))
{
return true;
}
baseType = baseType.BaseType;
}
return false;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsDerivedFromSmartContract returns true even when a asmart contract is derived for many times. e.g.
class A: SmartContract
class B: A
class C: B
IsDerivedFromSmartContract returns true for B and C. But in B and C we may call base
, or utilize the constructor of A.
TODO in the future: regex may not be reliable enough