My problem is that i keep having the error CS8652
"C# The feature is currently in Preview and unsupported. To use Preview features, use the language version."
By using "?" after the type to authorize the property to be null during a deserialization (i use JsonConvert if it helps, maybe there is a parameter that authorize some property to be null, but i don't really think so)
class Data
{
String? PropertyCanBeNull { get; set; }
}
I've tried almost all i've found to resolve this error including the following : - Install Visual Studio 2019 Preview - Install .NET SDK for preview (and checking in CMD that it worked) - Modified my project property so that it use the .NET Core 3.0+ version
I also tried to change the language version for my project, but it seems it's useless in my case.
"When your project targets a preview framework that has a corresponding preview language version, the language version used is the preview language version."
Source : https://learn.microsoft.com/fr-fr/dotnet/csharp/language-reference/configure-language-version
Answered by Dirk in comments :
I also remember using the "?" after the type some time ago, but i'm not really sure, did they do any change to it so that it is supported only in "preview" or something ?
Nullable value types (like int?) have been in C# for a very long time. Nullable reference types (like string?) however were introduced with C# 8.
A string is Always nullable in C#.
And while C# 8 will introduce the nullable reference types like public string?
this is also a problem NewtonSoft's JSON Converter has had solved for some time:
string ignored = JsonConvert.SerializeObject(movie,
Formatting.Indented,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
I made it back to the machine with Visual Studio, fully updated to Visual Studio 2019 (16.2):
If you edit the project solution
and add the following two settings to the PropertyGroup the warning will go away:
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>