Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
make log4net usable from a PublishAOT build (#306) #306
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
base: master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
make log4net usable from a PublishAOT build (#306) #306
Changes from all commits
bf839f7File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this logic quite a few times throughout - perhaps move to CallerAssembly with a lazy backing field and reference that static property elsewhere (eg
CallerAssembly.ResolvedCallerAssembly? Main reason being that it's no longer just an obvious call to Assembly.GetCallingAssembly(), but now includes logic, which is repeated in quite a few places.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fluffynuts
Good catch, but this one can't move - though I don't like it either.
Assembly.GetCallingAssembly()returns the caller of the method containing the call, so in a property on
CallerAssemblythe calleris log4net itself - every logger would land in log4net's own repository. Two-assembly harness,
called from
UserApp:The lazy backing field is worse: the first assembly to touch it wins forever, so the result depends on
load order.
The BCL hits this exact problem and needs an internal enum for it -
System.Threading.StackCrawlMark(
LookForMyCaller,LookForMyCallersCaller), passed byrefsoAssembly.Loadcan delegate to aprivate helper. It's
NotPublicand no public API accepts it. It also wouldn't help us: it'sstack-walking machinery, and AOT throws precisely because there is no stack to walk.
Only a Roslyn interceptor would actually remove the repetition - left out here, but I'm happy to open a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I think
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]is the bigger eyesore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I was also looking at that - but if I were to guess wildly, the attribute as found (when found) in the dotnet runtime, is likely sealed. Otherwise I'd suggest sub-classing with those settings - which still may not even work if the logic doesn't bother to look at attributes' base types (quite likely). I don't think there's much that can be done about it :/
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.