Skip to content

Conversation

SimonCropp
Copy link
Contributor

given in some contexts i build up a list of ILogEventEnricher of a (runtime) variable size. So the array nature of push forces a redundant array alloc.

this PR adds a params IEnumerable overload.

I am not sure on having the Obsolete? the OverloadResolutionPriority will point the compiler to IEnumerable overload. so it is not a compile time breaking change. and it is not a runtime breaking change. thoughts?

@nblumhardt
Copy link
Member

Makes sense 👍

I think since there's little chance we'd actually remove the original array version in the foreseeable future, and considering there might be scenarios in which it generates a warning (e.g. old compiler versions?), perhaps we drop the obsolete attribute?

Gave a bit of thought to whether we'd also want to provide a params ReadOnlySpan version, too; seems like it'd cover a slightly different set of cases and still be an option in a later version if we decided to include it then, so probably not, but just mentioning it in case you spot any conflicts/synergies with that hypothetical API.

@SimonCropp
Copy link
Contributor Author

perhaps we drop the obsolete attribute

done

Gave a bit of thought to whether we'd also want to provide a params ReadOnlySpan version

added

i also added some tests

@SimonCropp
Copy link
Contributor Author

i also removed the OverloadResolutionPriority. since if we want to keep the array varient around, there is no need to redirect

@SimonCropp
Copy link
Contributor Author

nudge

Copy link
Member

@nblumhardt nblumhardt left a comment

Choose a reason for hiding this comment

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

Thanks! 👍

Looks like CI is failing - stack overflow?

@SimonCropp
Copy link
Contributor Author

turns out i still need the OverloadResolutionPriority to point the compiler to the most efficient overload

@nblumhardt nblumhardt merged commit cd6420a into serilog:dev Mar 18, 2025
1 check passed
@SimonCropp SimonCropp deleted the allow-pushing-a-IEnumerable-of-ILogEventEnricher branch March 18, 2025 06:18
@nblumhardt nblumhardt mentioned this pull request May 13, 2025
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