Feature Nullable Reference Types not available
See original GitHub issueDescribe the bug When compiling a template I get the following errors
RazorLight.Compilation.TemplateCompilationException: Failed to compile generated Razor template:
- (11:1) Das Feature "Nullable-Verweistypen" ist in C# 7.3 nicht verfügbar. Verwenden Sie Sprachversion 8.0 oder höher.
- (17:1) Das Feature "Nullable-Verweistypen" ist in C# 7.3 nicht verfügbar. Verwenden Sie Sprachversion 8.0 oder höher.
- (24:1) Das Feature "Nullable-Verweistypen" ist in C# 7.3 nicht verfügbar. Verwenden Sie Sprachversion 8.0 oder höher.
- (30:1) Das Feature "Nullable-Verweistypen" ist in C# 7.3 nicht verfügbar. Verwenden Sie Sprachversion 8.0 oder höher.
- (32:1) Das Feature "Nullable-Verweistypen" ist in C# 7.3 nicht verfügbar. Verwenden Sie Sprachversion 8.0 oder höher.
- (38:1) Das Feature "Nullable-Verweistypen" ist in C# 7.3 nicht verfügbar. Verwenden Sie Sprachversion 8.0 oder höher.
Which translates to
The feature "Nullable reference type" is not available in C# 7.3. Use Version 8.0 or higher.
I’m not using nullable reference types anywhere in my model or template. My template isn’t even 38 lines long.
To Reproduce
- Create a classlib that targets
netcoreapp3.1
. - Create a ASP.NET Core App that targets
netcoreapp3.1
. - Install
RazorLight
into the classlib and reference it from the main project. - Add
IRazorLightEngine
to the DI via an extension method that is placed in the classlib
serviceCollection.AddSingleton<IRazorLightEngine>(_ =>
new RazorLightEngineBuilder()
.UseFileSystemProject(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MailTemplates"))
.UseMemoryCachingProvider()
.Build()
);
- Call this extension method in your
ConfigureServices
- Try to compile a template
Expected behavior The template compiles without errors.
Information (please complete the following information):
- OS: Windows 10 1909
- Platform .NET Core 3.1
- RazorLight version 2.0.0-beta4
- Visual Studio version Visual Studio Professional 2019
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Nullable reference types
Nullable reference types are a compile time feature. That means it's possible for callers to ignore warnings, intentionally use null as an ...
Read more >How to make reference type nullable in C# 7.3?
1 Answer 1 ... The compiler is asking you to use a newer version of the language, not a newer version of .NET....
Read more >Using C# 8 and Nullable Reference Types in .NET Framework
Changing C# versions require modifying the project file directly. · Globally enabling nullable reference types can only be done with the new ...
Read more >Nullable Reference types in C# – Best practices
TypeScript has the strictNullChecks option. · In Kotlin (preferred language for Android development), all types don't allow null values by ...
Read more >How to enable Nullable Reference Types
Learn how you can enable the Nullable Reference Types feature in C# 8 and start fixing nullability issues in your code base.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What helped in my case was to explicitly switch to C# 8 by adding
<LangVersion>8.0</LangVersion>
to somePropertyGroup
in the.csproj
files. Hope this helps!@jzabroski Thanks for this solution, I was also having this problem and spent like 3 hours trying to fix it and was literally about to submit an issue before GitHub referred me to this issue.