Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,26 @@
</ItemGroup>
</Target>

<!--
================================================================
FilterTemporaryAssemblyAnalyzers
================================================================

Name : FilterTemporaryAssemblyAnalyzers

This target runs only inside the temporary project, where it drops analyzers re-resolved on their own
(those lacking the parent's WpfTempProjectAnalyzers marker), keeping only the set flowed from the parent.

Condition: _WpfTempProjectIncludesPackageReferences == true
-->
<Target Name="FilterTemporaryAssemblyAnalyzers"
BeforeTargets="RemoveDuplicateAnalyzers;CoreCompile"
Condition="'$(_WpfTempProjectIncludesPackageReferences)' == 'true'">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="'%(Analyzer.WpfTempProjectAnalyzers)' != 'true'" />
</ItemGroup>
</Target>

<!--
================================================================
SatelliteOnlyMarkupCompilePass2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private bool ExecuteGenerateTemporaryTargetAssemblyWithPackageReferenceSupport()
AddNewItems(xmlProjectDoc, CompileTypeName, GeneratedCodeFiles);

// Add Analyzers to Analyzer item list.
AddNewItems(xmlProjectDoc, AnalyzerTypeName, Analyzers);
AddNewItems(xmlProjectDoc, AnalyzerTypeName, Analyzers, true);

// Replace implicit SDK imports with explicit SDK imports
ReplaceImplicitImports(xmlProjectDoc);
Expand All @@ -275,6 +275,7 @@ private bool ExecuteGenerateTemporaryTargetAssemblyWithPackageReferenceSupport()
( nameof(BaseIntermediateOutputPath), BaseIntermediateOutputPath ),
( nameof(MSBuildProjectExtensionsPath), MSBuildProjectExtensionsPath ),
( "_TargetAssemblyProjectName", Path.GetFileNameWithoutExtension(CurrentProject) ),
( "_WpfTempProjectIncludesPackageReferences", "true" ),
( nameof(RootNamespace), RootNamespace ),
};

Expand Down Expand Up @@ -694,7 +695,7 @@ private void RemovePropertiesByName(XmlDocument xmlProjectDoc, string sPropertyN
//
// Add a list of files into an Item in the project file, the ItemName is specified by sItemName.
//
private void AddNewItems(XmlDocument xmlProjectDoc, string sItemName, ITaskItem[] pItemList)
private void AddNewItems(XmlDocument xmlProjectDoc, string sItemName, ITaskItem[] pItemList, bool tagWpfTempProjectAnalyzers = false)
{
if (xmlProjectDoc == null || String.IsNullOrEmpty(sItemName) || pItemList == null)
{
Expand Down Expand Up @@ -744,6 +745,13 @@ private void AddNewItems(XmlDocument xmlProjectDoc, string sItemName, ITaskItem[
nodeItem.AppendChild(embedItem);
}

if (tagWpfTempProjectAnalyzers)
{
XmlElement metadataItem = xmlProjectDoc.CreateElement(WPFTEMPPROJECTANALYZERS, root.NamespaceURI);
metadataItem.InnerText = "true";
nodeItem.AppendChild(metadataItem);
}

// Add current item node into the children list of ItemGroup
nodeItemGroup.AppendChild(nodeItem);
}
Expand Down Expand Up @@ -936,6 +944,8 @@ private static XmlNode CreateImportProjectSdkNode(XmlDocument xmlProjectDoc, str

private const string WPFTMP = "wpftmp";

private const string WPFTEMPPROJECTANALYZERS = "WpfTempProjectAnalyzers";

private static readonly char[] s_semicolonChar = [';'];

#endregion Private Fields
Expand Down