-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
LoggingConfigurationParser - Moved attribute validation from Xml-Config #3466
LoggingConfigurationParser - Moved attribute validation from Xml-Config #3466
Conversation
26298fc
to
966e30a
Compare
172d851
to
009c32a
Compare
009c32a
to
d7845ab
Compare
Codecov Report
@@ Coverage Diff @@
## dev #3466 +/- ##
======================================
- Coverage 81% 81% -<1%
======================================
Files 345 345
Lines 27886 27917 +31
Branches 3778 3798 +20
======================================
+ Hits 22483 22497 +14
- Misses 4305 4322 +17
Partials 1098 1098 |
0b7d9dd
to
d8efb55
Compare
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.
cool, so no breaking change in the interface 👍
_validChildren.Add(validChild); | ||
yield return validChild; | ||
} | ||
_validChildren = _validChildren ?? ArrayHelper.Empty<ValidatedConfigurationElement>(); |
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.
This is a bit unexpected (according to the method name)
could we move this out of this method, or rename the method (YieldAndCacheValidChildren or something like that)
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.
Will rename the method as suggested. But the reason is to perform lazy validation of children (But only once)
@@ -1295,9 +1278,122 @@ private static string GetName(Target target) | |||
return string.IsNullOrEmpty(target.Name) ? target.GetType().Name : target.Name; | |||
} | |||
|
|||
private class ValidatedConfigurationElement : ILoggingConfigurationElement |
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 which level this element is "Validated"? I don't fully understand the class name
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.
It currently performs validation of attribute-name-uniqueness., But more validation can be added later (Ex. valid element-Name)
PS:
The unnamed property wasn't suddenly for me, and please note it's not unique for XML (yes, it isn't in JSON). |
Lets say config-item in Nlog has 2 attributes (or more). How do you specify which attribute is configured by the unnamed-property-value? If you want Xml-config to automatically update the "value"-property (on whatever config-item in question) when using xml-element-value. Then you should implement this magic in the xml-element-node, so it yields the unnamed xml-element-value as a bonus attribute with |
d8efb55
to
85d58c7
Compare
@snakefoot now it's my time for holiday :) |
Great idea. Rome is very nice. No hurry with the PRs. Enjoy the holiday :)
|
-> snakefoot#9 |
Seems your removal of my explicit cast has now broken the build: https://ci.appveyor.com/project/nlog/nlog/builds/25516652 And https://travis-ci.org/NLog/NLog/builds/550093878?utm_source=github_status&utm_medium=notification |
OK, I will check that. Locally it works without cast. |
Unfortunately the logs are always a bit unclear. I forgot .NET 3.5 doesn't support covariance interfaces :( |
No the validation introduced with this PR just makes sure you don't have invalid configuration. You have created the invalid test config after this PR was introduced. |
…buteHasPrecedence (Ignore invalid config)
cbf669f
to
ba2e4de
Compare
Have now fixed |
Thanks! |
Improves the validation for
NLogLoggingConfiguration
(appsettings-json)Removing
Value
fromILoggingConfigurationElement
. Unless full support for checking the Value in all locations where possible (And not just for variables). And also avoid too much diversion from XML and JSON-config (Suddenly supporting unnamed-properties).Instead one can do this, where one assigns the
value
-property (and allow<layout>
as alias):