NTypewriter
NTypewriter copied to clipboard
Using C# 9.0 init accessors in a custom function gives an error inside Visual Studio extension
When using init accessors or primary constructors on records inside a custom (*.nt.cs) function
public class Sum
{
public int X { get; init; }
public int Y { get; init; }
}
Or
public record Sum(int X, int Y)
Gives the following error
error CS0518: Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported
To fix the error you need to add the following code inside the custom function.
namespace System.Runtime.CompilerServices
{
[EditorBrowsable(EditorBrowsableState.Never)]
internal static class IsExternalInit { }
}
It would be great if this can be added automatically by the Visual Studio extension itself.
We will see about that, officially only .net standard 2.0 and C# 7.3 are supported in the custom function.