Expose CompilerVisibleProperty to AnalyzerConfigOptionsProvider.GlobalOptions by Corniel · Pull Request #301 · Buildalyzer/Buildalyzer · GitHub
Skip to content

Expose CompilerVisibleProperty to AnalyzerConfigOptionsProvider.GlobalOptions - #301

Open
Corniel wants to merge 1 commit into
Buildalyzer:mainfrom
Corniel:compiler-visible-property
Open

Corniel wants to merge 1 commit into
Buildalyzer:mainfrom
Corniel:compiler-visible-property

Conversation

@Corniel

@Corniel Corniel commented Feb 19, 2025

Copy link
Copy Markdown
Collaborator

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.

@Corniel
Corniel force-pushed the compiler-visible-property branch from 53419f0 to 142f38b Compare April 18, 2026 12:23
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