-
Notifications
You must be signed in to change notification settings - Fork 102
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
fix Biginteger default. #1242
base: master
Are you sure you want to change the base?
fix Biginteger default. #1242
Conversation
In what case do we utilize BigInteger default value as null? |
neo-devpack-dotnet/src/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj Line 4 in 34926a0
I think enabling nullable is enough (in PR 1214) |
I personally dont think we should enable nullable in contract, not really being much help to contract but introduces many complex work in compiler.... but since we already have it, so, lets complete 1214 then. |
Nullable simply gives more hints to the user, and does not affect the compiler. If nullable is false, everything can be silently null, being more dangerous. |
Not in this pr, i mean compiler level nullable support that we already have, nullable value requires extra checks and increases the complexity. |
In this PR we are trying to mark BigInteger declared in method. However, if we apply this methodology, then for all types of variables declared in methods, they are all null, and all have to be checked with many efforts. Thus using in csproj brings more efficient and accurate checks, for free. |
{ | ||
// The default BigInteger is null. | ||
// But object creation will assign BigInteger a default value | ||
if (fields[i].Type.Name == nameof(BigInteger)) |
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.
Its better to check types with namespace
This pr fix the BigInteger default value.
When we define a BigInteger, it will not be assigned a default value like int, but it will remain as null.
but when it is defined in a class/struct, the defualt constructor of of class/struct will assign it a default value.