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

Expose CompilerVisibleProperty to AnalyzerConfigOptionsProvider.GlobalOptions #301

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Corniel
Copy link
Contributor

@Corniel Corniel commented Feb 19, 2025

When creating a .csproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <CustomProperty>Custom value</CustomProperty>
  </PropertyGroup>

 <ItemGroup>
   <CompilerVisibleProperty Include="CustomProperty" />
 </ItemGroup>
 
</Project>

The value of the <CustomProperty> is exposed to the AnalyzerConfigOptionsProvider.GlobalOptions within the context of a Roslyn code analyzer. How Roslyn solves this is as follows:

It generates an .editorcofig file with the name: obj/{Configuratioin}/{TargetFrameWork}/{ProjectFileName}.GeneratedMSBuildEditorConfig.editorconfig.

In the reproducer this is the body:

is_global = true
build_property.CustomProperty = Custom value
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion = 
build_property.UsingMicrosoftNETSdkWeb = 
build_property.ProjectTypeGuids = 
build_property.InvariantGlobalization = 
build_property.PlatformNeutralAssembly = 
build_property.EnforceExtendedAnalyzerRules = 
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = CompilerVisibleProperty
build_property.ProjectDir = ~\buildalyzer\tests\projects\CompilerVisibleProperty\
build_property.EnableComHosting = 
build_property.EnableGeneratedComInterfaceComImportInterop = 
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity = 

To actually solve this, this file has to be added to the AnalyzerConfig somehow. I'm not sure if this can be achieved in Buildalyzer, or that it is only possible to do this when spinning up the diagnostics.

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.

1 participant