You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose you have three totally independent packages that provide analyzers that leverage additional files to do some processing. Additionally, all packages consume the same file types (i.e. .resx files).
The first package might just add the files as AdditionalFiles and check for file extension inside the analyzer:
The second package, however, might use an additional piece of metadata for the embedded resources to distinguish them, and thus has a slightly different version:
<ItemGroup>
<CompilerVisibleItemMetadataInclude="AdditionalFiles"MetadataName="SourceItemType" />
<!-- NOTE: added again, same identity, but with the additional metadata this time -->
<AdditionalFilesInclude="@(EmbeddedResource)"SourceItemType="EmbeddedResource" />
</ItemGroup>
A third one might even use another totally different metadata annotation on the same items for its own purposes:
Regardless of the somewhat unintuitive behavior when retrieving this item's metadata from the analyzer using the AnalyzerConfigOptionsProvider for that file (will you get the empty value or EmbeddedResource when asking for SourceItemType with .TryGetValue("build_metadata.AdditionalFiles.SourceItemType", out var value)?), if you have many files and multiple packages leveraging compiler item metadata, this duplication can make the editorconfig unnecessarily large (and potentially impossible to get the right value, depending on whichever behavior Roslyn itself provides for such duplicated entries).
Steps to Reproduce
<ProjectSdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- Some nuget package via .targets -->
<ItemGroup>
<AdditionalFilesInclude="@(EmbeddedResource)" />
</ItemGroup>
<!-- Some other package via .targets -->
<ItemGroup>
<CompilerVisibleItemMetadataInclude="AdditionalFiles"MetadataName="SourceItemType" />
<!-- NOTE: added again, same identity, but with the additional metadata this time -->
<AdditionalFilesInclude="@(EmbeddedResource)"SourceItemType="EmbeddedResource" />
</ItemGroup>
<!-- A third package via .targets -->
<ItemGroup>
<CompilerVisibleItemMetadataInclude="AdditionalFiles"MetadataName="Foo" />
<!-- NOTE: added again, same identity, but with the additional metadata this time -->
<AdditionalFilesInclude="@(EmbeddedResource)"Foo="Bar" />
</ItemGroup>
</Project>
Expected Behavior
Emitted editorconfig similar to:
[.../Resources.resx]
build_metadata.AdditionalFiles.SourceItemType = EmbeddedResourcebuild_metadata.AdditionalFiles.Foo = Bar
Issue moved from dotnet/msbuild#10309
From @kzu on Friday, June 28, 2024 5:43:42 PM
Issue Description
Suppose you have three totally independent packages that provide analyzers that leverage additional files to do some processing. Additionally, all packages consume the same file types (i.e.
.resx
files).The first package might just add the files as
AdditionalFiles
and check for file extension inside the analyzer:The second package, however, might use an additional piece of metadata for the embedded resources to distinguish them, and thus has a slightly different version:
A third one might even use another totally different metadata annotation on the same items for its own purposes:
The resulting editorconfig will currently now look like the following:
Regardless of the somewhat unintuitive behavior when retrieving this item's metadata from the analyzer using the
AnalyzerConfigOptionsProvider
for that file (will you get the empty value orEmbeddedResource
when asking forSourceItemType
with.TryGetValue("build_metadata.AdditionalFiles.SourceItemType", out var value)
?), if you have many files and multiple packages leveraging compiler item metadata, this duplication can make the editorconfig unnecessarily large (and potentially impossible to get the right value, depending on whichever behavior Roslyn itself provides for such duplicated entries).Steps to Reproduce
Expected Behavior
Emitted editorconfig similar to:
Actual Behavior
Emitted editorconfig is actually similar to:
Analysis
No response
Versions & Configurations
17.11.0.27902
The text was updated successfully, but these errors were encountered: