Metadata, dependency injection, web and interop

This part of the C# course reads and extends a program from outside it. Reflection and attributes come first, then source generators and expression trees, and dependency injection in a console application. A minimal ASP.NET Core API follows with the client that calls it, and the part ends with two lessons of P/Invoke: a call into libc, and the marshalling a struct and a string need at that boundary.

8.1 Reflection typeof, GetMethods, Invoke, the link to gettype.php Open 8.2 Attributes an attribute, AttributeUsage, reading it back, the attributes of the BCL Open 8.3 Source generators what one is, what the SDK ships, why an analyzer package needs the network Open 8.4 Expression trees Expression<Func<...>>, building a tree, compiling it Open 8.5 Dependency injection ServiceCollection from the shared framework, lifetimes, a console app Open 8.6 A minimal ASP.NET Core API Kestrel on a port, MapGet, Results.Json, started here Open 8.7 Calling the API curl and python3 urllib, the JSON that came back Open 8.8 P/Invoke into libc DllImport, getpid, strlen, Marshal Open 8.9 Marshalling strings and structs StructLayout, blittable types, strings across the boundary, FieldOffset Open 8.10 A library and the project that uses it a class library, dotnet add reference, the build Open

Lessons