ch-robinson / dotnet-avro

An Avro implementation for .NET
https://engineering.chrobinson.com/dotnet-avro/
MIT License
135 stars 51 forks source link

Add tests for code generation #293

Closed runerys closed 9 months ago

runerys commented 9 months ago

This PR is dependent on features in PR #292 (separated as requested)

Since this is dependent on PR #292, those PR-changes are in this change set as well. I will rebase this PR if the first one gets merged.

runerys commented 9 months ago

This is cool! Do you know offhand whether it'll work on .NET Framework as well? Currently our CI runs on both .NET 8 and Framework 4.6.2; we'd have to carve out an exception if this can't run on both targets: https://github.com/ch-robinson/dotnet-avro/blob/main/.github/workflows/test.yml#L22

I fixed it. The original version used features from the assembly System.Runtime.Loader, but this is not available on net462. However, good old Assembly.Load() can take a byte array.


ms.Seek(0, SeekOrigin.Begin);

// net8
return AssemblyLoadContext.Default.LoadFromStream(ms);

// both net462 and net8
return Assembly.Load(ms.ToArray());

I guess loading from the stream (net8 version) is more effective, but loading a byte array should be perfectly fine here.

dstelljes commented 9 months ago

Nice, this should be good to go once it's rebased onto main

runerys commented 9 months ago

Nice, this should be good to go once it's rebased onto main

Done ✔