This code without the generator:
usingMicrosoft.Extensions.Configuration;Environment.SetEnvironmentVariable("Value","42");IConfigurationb=newConfigurationBuilder().AddEnvironmentVariables().Build();Based=newDerived();b.Bind(d);Console.WriteLine(d.Value);internalabstractclassBase{publicintValue{get;set;}}internalsealedclassDerived:Base{}prints 42.
With the config generator, that same code throws an exception, because the generator emits this:
publicstaticvoidBind_Base(thisIConfigurationconfiguration,object?obj){thrownewInvalidOperationException("Cannot create instance of type '<global namespace>.Base' because it is missing a public instance constructor.");}
This code without the generator:
prints
42.With the config generator, that same code throws an exception, because the generator emits this: