Skip to content

Commit

Permalink
Switch to built-in item metadata for manifest analyzer files
Browse files Browse the repository at this point in the history
This avoids duplicating metadata with other file types in the generated .editorconfig.

See dotnet/msbuild#10309
  • Loading branch information
kzu committed Jun 28, 2024
1 parent 1019e2a commit 49c9a38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void Initialize(AnalysisContext context)
{
var manifests = ctx.Options.AdditionalFiles
.Where(x =>
ctx.Options.AnalyzerConfigOptionsProvider.GetOptions(x).TryGetValue("build_metadata.AdditionalFiles.SourceItemType", out var itemType) &&
ctx.Options.AnalyzerConfigOptionsProvider.GetOptions(x).TryGetValue("build_metadata.SponsorManifest.ItemType", out var itemType) &&
itemType == "SponsorManifest" &&
Sponsorables.ContainsKey(Path.GetFileNameWithoutExtension(x.Path)))
.ToImmutableArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<!-- All GH manifests. For now, we don't support other funding platforms -->
<SponsorManifest Include="$(SponsorLinkHome)/github/*.jwt" />

<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemType" />
<CompilerVisibleItemMetadata Include="SponsorManifest" MetadataName="ItemType" />

<!-- To quickly exit if true -->
<CompilerVisibleProperty Include="DesignTimeBuild" />
</ItemGroup>
Expand All @@ -33,7 +34,7 @@
<Target Name="SL" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" DependsOnTargets="$(SLDependsOn)">
<ItemGroup>
<!-- Make manifests visible to analyzers -->
<AdditionalFiles Include="@(SponsorManifest -> Distinct())" SourceItemType="SponsorManifest" />
<AdditionalFiles Include="@(SponsorManifest -> Distinct())" />
</ItemGroup>
</Target>

Expand Down

0 comments on commit 49c9a38

Please sign in to comment.