Reputation: 19285
Take this simple code markdown:
```cs
var x = new Locked<Rec>(new ("John", 35));
```
This renders in GitHub readme like this:
I now just add a definition:
```cs
record Rec(string Name, int Age);
var x= new Locked<Rec>(new ("John", 35));
```
and it now renders like this:
As you can see the type Locked
and the new
are for some reason no longer coloured purple. Why is this and how can I get around it ?
Upvotes: 0
Views: 771
Reputation: 136938
Visual Studio Code does the same thing.
I'm not a C# developer, but the examples I found all instantiate the record inside Main
:
```cs
record Rec(string Name, int Age);
public static void Main()
{
var x = new Locked<Rec>(new ("John", 35));
}
```
This seems to get both VSCode and GitHub to highlight syntax as you expect:
It works even better if you declare the record inside Main
as well:
Upvotes: 1