Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #723 - Add Support ignore member when creating a constructor in DynamicTypeGenerator #754

Draft
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

DocSvartz
Copy link

No description provided.

@DocSvartz DocSvartz changed the title Fix issue #723 - Add Support ignore member constructor creation in DynamicTypeGenerator Fix issue #723 - Add Support ignore member when creating a constructor in DynamicTypeGenerator Jan 7, 2025
@DocSvartz
Copy link
Author

Hello @andrerav .

If the interface contains at least one property with a non-public setter, then all properties will be initialized via the constructor.
Custom logic for ignoring them is not supported.

I found a way to add this support, but maybe it was not intended that way?

@@ -175,5 +186,27 @@ private static void CreateMethod(TypeBuilder builder, MethodInfo interfaceMethod

builder.DefineMethodOverride(classMethod, interfaceMethod);
}

private static List<FieldBuilder> DropIgnorMemebers(List<FieldBuilder> fields)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly a typo: DropIgnoredMembers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes of course. This is not the final solution, you could say MVP :)

@@ -22,6 +22,16 @@ internal static class DynamicTypeGenerator
private static readonly ConcurrentDictionary<Type, Type> _generated = new ConcurrentDictionary<Type, Type>();
private static int _generatedCounter;

private static IgnoreDictionary ignoreMembers;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be nullable?

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