diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props
index 5347ee269625..ec047fdaf914 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props
@@ -169,9 +169,9 @@
+ A list of analyzer suppressions to include in every generated class.
+ This is required for roslyn analyzers that do not support the GeneratedCodeAttribute.
+ -->
@@ -180,6 +180,12 @@
+
+
+
diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs
index db85eb0ec52e..2db54e020376 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs
@@ -49,6 +49,7 @@ private class SerializationMethodsGenerator : SymbolVisitor
private readonly INamedTypeSymbol? _iFrameworkElementSymbol;
private readonly INamedTypeSymbol? _frameworkElementSymbol;
private readonly bool _isUnoSolution;
+ private readonly string[] _analyzerSuppressions;
public SerializationMethodsGenerator(GeneratorExecutionContext context)
{
@@ -68,6 +69,7 @@ public SerializationMethodsGenerator(GeneratorExecutionContext context)
_iFrameworkElementSymbol = comp.GetTypeByMetadataName(XamlConstants.Types.IFrameworkElement);
_frameworkElementSymbol = comp.GetTypeByMetadataName("Windows.UI.Xaml.FrameworkElement");
_isUnoSolution = _context.GetMSBuildPropertyValue("_IsUnoUISolution") == "true";
+ _analyzerSuppressions = context.GetMSBuildPropertyValue("XamlGeneratorAnalyzerSuppressionsProperty").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
}
public override void VisitNamedType(INamedTypeSymbol type)
@@ -164,6 +166,8 @@ private void ProcessType(INamedTypeSymbol typeSymbol)
builder.AppendLineInvariant(@"[global::Windows.UI.Xaml.Data.Bindable]");
}
+ AnalyzerSuppressionsGenerator.Generate(builder, _analyzerSuppressions);
+
var internalDependencyObject = _isUnoSolution && !typeSymbol.IsSealed ? ", IDependencyObjectInternal" : "";
using (builder.BlockInvariant($"partial class {typeSymbol.Name} : IDependencyObjectStoreProvider, IWeakReferenceProvider{internalDependencyObject}"))