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

Automatically set Id for native contracts #2210

Merged
merged 5 commits into from
Jan 10, 2021
Merged

Automatically set Id for native contracts #2210

merged 5 commits into from
Jan 10, 2021

Conversation

erikzhang
Copy link
Member

No description provided.

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change


public static IReadOnlyCollection<NativeContract> Contracts { get; } = contractsList;
#region Named Native Contracts
public static ContractManagement ContractManagement { get; } = new ContractManagement();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can init this contracts inside the static constructor in order to avoid that the compiler optimizer play with us.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually only partial classes have non-deterministic problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it's safer because this part is uncontrolled by us.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't want to modify every native contract each time we create a new one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if we use this code, we can avoid it?

[MethodImpl(MethodImplOptions.NoOptimization)]
static NativeContract() { }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be any problem without this code.

shargon
shargon previously approved these changes Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants