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

ConditionMethodExpression - Without reflection by default #5260

Closed
snakefoot opened this issue Jun 17, 2023 · 0 comments · Fixed by #5268
Closed

ConditionMethodExpression - Without reflection by default #5260

snakefoot opened this issue Jun 17, 2023 · 0 comments · Fixed by #5268
Labels
enhancement Improvement on existing feature up-for-grabs
Milestone

Comments

@snakefoot
Copy link
Contributor

snakefoot commented Jun 17, 2023

ConditionMethodExpression should not use reflection by default, but it should be the fallback option. Instead one should initialize with a standard lambda-delegate.

Registration of builtin condition-methods, should happen upfront.

See also: #1779 + #5258

Replacing this logic with registration of lambda-delegates:

private static ConfigurationItemFactory BuildDefaultFactory()
{
var factory = new ConfigurationItemFactory(LogManager.LogFactory.ServiceRepository, null);
lock (SyncRoot)
{
AssemblyExtensionTypes.RegisterTypes(factory);
factory.ConditionMethodFactory.RegisterType(typeof(NLog.Conditions.ConditionMethods), string.Empty);

Maybe just focus on having lamdba-delegates with 1 or 2 parameters:

  • 1 parameter delegates can be used for transformation
  • 2 parameter delegates can be used for comparison

Then obsolete methods with bonus parameter to ignore-case, instead just have 2 methods and use the one with the wanted ignores-case-behavior. Also mark ConditionMethodExpression as obsolete, and all logic that depends on upon it.

Maybe have some method "selection" based on the number of parameters found by the parser, so having the ability to register the same method-name multiple times, but with different number of parameters. Have validation whether method is available to support the provided input-parameters.

@snakefoot snakefoot added enhancement Improvement on existing feature up-for-grabs labels Jun 17, 2023
@snakefoot snakefoot changed the title ConditionMethodExpression - Without reflection ConditionMethodExpression - Without reflection by default Jun 17, 2023
@snakefoot snakefoot added this to the 5.2.1 milestone Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement on existing feature up-for-grabs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant