question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Nullable Reference Types not available

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
hwinkelmanncommented, Mar 6, 2020

What helped in my case was to explicitly switch to C# 8 by adding <LangVersion>8.0</LangVersion> to some PropertyGroup in the .csproj files. Hope this helps!

0reactions
dariel312commented, Mar 9, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found