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

C# 8.0 nullable types not supported #553

Closed
mohitatray opened this issue Jul 26, 2020 · 4 comments
Closed

C# 8.0 nullable types not supported #553

mohitatray opened this issue Jul 26, 2020 · 4 comments

Comments

@mohitatray
Copy link

mohitatray commented Jul 26, 2020

string? text = "mohit"

Question mark should not be highlighted as syntax error as it specifies that variable is nullable string.
Implement nullable types in C# 8.0.

@mohitatray mohitatray changed the title C# 8.0 nullable types C# 8.0 nullable types not supported Jul 26, 2020
@VISTALL
Copy link
Member

VISTALL commented Jul 26, 2020

Hello. I will suppress this check for 8+ version. Can you say .net version which you use? (unity maybe version), etc

Thanks

@mohitatray
Copy link
Author

<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
Although the .net version doesn't matter, you can use C# 8.0 nullable types even in .net 2.0. C# version is totally independent of .net version. C# 8.0 is the C# compiler version whereas .net version is which framework the app depends on.

I am using Consulo for working on a Mono project (and added GTK sharp NuGet package to make GTK apps).

You also need to do null checks. For example let's say you have a method which takes in a string like this --

void Trim(string s) {
    // Some code
}

Now you are not allowed to call this method with null parameter like this --
Trim(null); // Passing null is not allowed because parameter is a non-null string type
Because Trim method takes in a parameter which is a non-null string type, you cannot call Trim(null). It should atleast show a warning if not error.

This is only applicable for C# 8.0. Nothing is changed in C# versions before that.
In C# 8.0, every reference type which doesn't have ? at the end is a non-null type. You cannot assign null to it.

@VISTALL
Copy link
Member

VISTALL commented Jul 26, 2020

Thanks - .NET version just for testing.

@VISTALL
Copy link
Member

VISTALL commented Jul 26, 2020

Hello. I added suppressing CS0453 for C# 8+ code for disable red code.

After my review i create new issue - #554.

Need some time for fix all those problems.

Thanks

@VISTALL VISTALL closed this as completed Jul 26, 2020
VISTALL added a commit that referenced this issue Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants