Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Conversation

@obones
Copy link
Contributor

@obones obones commented Jan 21, 2021

While working on Linux unit tests (#304), I came across the way the xslFiles section is accessed.
The current code is using ConfigurationManager.GetSection("xslFiles") and casts it directly to an IList instance. Unfortunately, for a reason that I could not identify, this always returns null under Linux/Mono.
However, using ConfigurationManager.OpenExeConfiguration gives me a valid filePath along with a non null value for the GetSection code.
Unfortunately, the returned object is a DefaultSection instance that does not cast to IList at all.

This led me to review the code that "reads" this from the .config file and I discovered that it is implemented via the XslFilesSectionHandler class. It does so by implementing the IConfigurationSectionHandler interface which has been deprecated for a long time now.
Changing the code to follow today's standards allows to get an instance of XslFilesSectionHandler returned by GetSection and as such access any code on it that could return a list of strings as expected by users of this section.

This pull request implements the required changes and with those, I have solved failed tests 2, 3 and 4.

Note that there is another location where GetSection is called, inside CruiseServerFactory.CreateLocal, along with the ServerConfigurationHandler section handler that implements IConfigurationSectionHandler. I believe the same set of changes is required there as well.

There is one last usage of IConfigurationSectionHandler, and it's in CruiseControlConfigSectionHandler. But I don't understand its usage as its Create method returns null in all cases. Maybe it should just be removed.

…inherit from ConfigurationSection and implement the hiearchy via collections and elements
… fall back to opening a configuration manually. This is happening under Linux/Mono for instance.
@savornicesei savornicesei merged commit bcb43c3 into ccnet:master Feb 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants