We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Gold Aegis • 3 years ago

A lot of uh ohs in this chapter

Fakhrulhilal Maktum • 3 years ago

Awesome, I just realize that we can patch .NET core 3.1 to use inline record style here. Many thanks for sharing this.

Andrew Arnott • 4 years ago

Great write-up. FWIW the VB.NET compiler can read properties with init setters from C#, at least in VS 16.10.

Also a very important point about defining your own IsExternalInit class: if you ever do it, you must do it for all target frameworks, and forever after. The reason is that the modreq stores the assembly of its type argument, and if that were to ever change, its a binary breaking change since all callers also store the assembly of the modreq type argument wherever they call that init accessor. If a target framework change or later version of your library were to change the assembly that the IsExternalInit was referenced from, all assemblies that compiled against the other version would fail with a MissingMethodException.
Fortunately, the C# compiler does not complain about you defining that type when targeting net5.0, and it will prefer yours over the one in System.Runtime, so it works out.