Use C# 9 records in non-net5.0 projects
The new C# 9 records syntax is quite nice:
When using it in a non-net5.0 project (i.e. netstandard2.0), compilation fails with an error:
To workaround the issue, simply declare the missing type in your project:
(as seen elsewhere too). Note the class doesn't even need to be public.
If you're multitargeting net5.0 and other TFMs, just add this bit of MSBuild to remove it for net5.0 since it's built-in:
PreviousPersisting output files from source generatorsNextAsyncLocal never leaks and is safe for CallContext-like state
Last updated