FirelyTeam / firely-cql-sdk

BSD 3-Clause "New" or "Revised" License
30 stars 17 forks source link

AssemblyLoadContext.Run fails, because libraries are singletons now. #609

Closed baseTwo closed 1 month ago

baseTwo commented 1 month ago

As a result of #575 changing libraries to singletons, an oversight was to update the AssembleLoadContextExtensions which run these libraries.

@baseTwo It seems as if the code-generation creates only a private default constructor:

[System.CodeDom.Compiler.GeneratedCode(".NET Code Generation", "2.0.6.0")]
[CqlLibrary("CqlNestedTupleTest", "1.0.0")]
public partial class CqlNestedTupleTest_1_0_0 : ILibrary, ISingleton<CqlNestedTupleTest_1_0_0>
{
    private CqlNestedTupleTest_1_0_0() {}

That's correct. For performance reasons, libraries are accessible through a singleton property Instance on the library type. (see PR# 585. > This has been applied on v1.0 too.

It seems the AssemblyLoadContext.Run method still needs to be updated for this. I'll add a ticket to fix that, and add some unit tests for it as well. Originally posted by @baseTwo in https://github.com/FirelyTeam/firely-cql-sdk/issues/603#issuecomment-2416418619