Skip to content

Conversation

@ybavli-dsc
Copy link
Contributor

fix: safely load assemblies in ConcertoTypeDictionary

Changes

Change assembly.GetTypes() to a more lenient approach "GetLoadableTypes()" where ReflectionTypeLoadException is being ignored, and we load only the types that we are able to load.

The reason for this is that there may be some dlls that will fail to load, which will fail the entire flow.
For example, the following error (which happened):

ReflectionTypeLoadException : Unable to load one or more of the requested types.
Could not load type 'SqlGuidCaster' from assembly 'System.Data.SqlClient, Version=4.6.1.6, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field."

This way, a single faulty/incompatible assembly won't fail the entire flow

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests -- this is an edge case error handling. the main flow is covered by existing unit tests. Reproducing the actual error with faulty DLLs has low ROI.
  • Commits messages follow AP format
  • Extend the documentation, if necessary -- this is an internal change, and doesn't require documentation changes
  • Merging to main from ybavli-dsc:main

- Update all projects' target framework in `.NET8.0` (from `standard2.0`)
- Update all projects' C# version to 12 (from 10)
- Updated NuGet packages
- Fixes for compilation:
1. `ConcertoConverter.deserializeWithGenericType` chose the wrong overloaded method. Added expected parameters to choose the correct method.
2. Added `Decorator.cs` to declare the existence of `AccordProject.Concerto.Decorator` namespace, because the code generation script added `using AccordProject.Concerto.Decorator` for some reason and the compilation failed.

Signed-off-by: Yuval Bavli <[email protected]>
Change assembly.GetTypes() to a more lenient approach "GetLoadableTypes()" where ReflectionTypeLoadException is being ignored, and we load only the types that we are able to load.

The reason for this is that there may be some dlls that will fail to load which will fail the entire flow.
For example the following error (which happened):
ReflectionTypeLoadException : Unable to load one or more of the requested types.\nCould not load type 'SqlGuidCaster' from assembly 'System.Data.SqlClient, Version=4.6.1.6, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field."

Signed-off-by: Yuval Bavli <[email protected]>
@jamieshorten jamieshorten merged commit a407adb into accordproject:main Mar 13, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants