msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Feature Request]: Specify the .editorconfig path when incorrect value is specified

Open f-alizada opened this issue 1 year ago • 0 comments

Summary

Current implementation of ConfigurationProvider and initiating instances of BuildAnalyzerConfiguration could result exception and build error in case the configuration was provided incorrectly: https://github.com/dotnet/msbuild/blob/main/src/Build/BuildCheck/API/BuildAnalyzerConfiguration.cs#L95-L100

    private static void ThrowIncorrectValueException(string key, string value)
    {
        // TODO: It will be nice to have the filename where the incorrect configuration was placed. 
        throw new BuildCheckConfigurationException(
                $"Incorrect value provided in config for key {key}: '{value}'",
                buildCheckConfigurationErrorScope: BuildCheckConfigurationErrorScope.EditorConfigParser);

The exception shows only incorrect value, however there is no information on which file was used for this specific value.

Background and Motivation

In case there are multiple upper directories with editorconfig containing incorrect values it not clear from which exactly was incorrect value was used and resulted build to fail

Proposed Feature

Include the full path of .editorconfig from where the incorrect value was parsed. The change will require updating the current parsing logic and have additional information per the option with the file information from where it was fetched (increases the usage of memory)

f-alizada avatar Jul 13 '24 11:07 f-alizada