92 instantiations of Suppression
Microsoft.DotNet.ApiCompatibility (4)
Logging\SuppressionEngine.cs (3)
70Suppression globalTargetSuppression = new(error.DiagnosticId, error.Target, isBaselineSuppression: error.IsBaselineSuppression); 73Suppression globalLeftRightSuppression = new(string.Empty, left: error.Left, right: error.Right, isBaselineSuppression: error.IsBaselineSuppression); 76Suppression globalDiagnosticIdLeftRightSuppression = new(error.DiagnosticId, left: error.Left, right: error.Right, isBaselineSuppression: error.IsBaselineSuppression);
Runner\ApiCompatRunner.cs (1)
68Suppression suppression = new(difference.DiagnosticId)
Microsoft.DotNet.ApiCompatibility.Tests (80)
Logging\SuppressionEngineTests.cs (37)
16Suppression suppression = new("PKG004", "A.B()", "ref/net6.0/mylib.dll", "lib/net6.0/mylib.dll"); 33Assert.True(suppressionEngine.IsErrorSuppressed(new Suppression("CP0001", "T:A.B", "ref/netstandard2.0/tempValidation.dll", "lib/net6.0/tempValidation.dll"))); 34Assert.False(suppressionEngine.IsErrorSuppressed(new Suppression("CP0001", "T:A.C", "ref/netstandard2.0/tempValidation.dll", "lib/net6.0/tempValidation.dll"))); 35Assert.False(suppressionEngine.IsErrorSuppressed(new Suppression("CP0001", "T:A.B", "lib/netstandard2.0/tempValidation.dll", "lib/net6.0/tempValidation.dll"))); 36Assert.True(suppressionEngine.IsErrorSuppressed(new Suppression("PKV004", ".netframework,Version=v4.8"))); 37Assert.False(suppressionEngine.IsErrorSuppressed(new Suppression(string.Empty, string.Empty))); 38Assert.False(suppressionEngine.IsErrorSuppressed(new Suppression("PKV004", ".netframework,Version=v4.8", "lib/net6.0/mylib.dll"))); 39Assert.False(suppressionEngine.IsErrorSuppressed(new Suppression("PKV004", ".NETStandard,Version=v2.0"))); 40Assert.True(suppressionEngine.IsErrorSuppressed(new Suppression("CP123", "T:myValidation.Class1", isBaselineSuppression: true))); 41Assert.False(suppressionEngine.IsErrorSuppressed(new Suppression("CP123", "T:myValidation.Class1", isBaselineSuppression: false))); 42Assert.True(suppressionEngine.IsErrorSuppressed(new Suppression("CP0001", "T:A.B", "ref/netstandard2.0/tempValidation.dll", "lib/net6.0/tempValidation.dll"))); 113Suppression usedSuppression = new("CP0001", "T:A", "lib/netstandard1.3/tempValidation.dll", "lib/netstandard1.3/tempValidation.dll"); 159engine.AddSuppression(new Suppression("CP0001", "T:A.B", isBaselineSuppression: true)); 160engine.AddSuppression(new Suppression("CP0001", "T:A.C")); 162Assert.True(engine.IsErrorSuppressed(new Suppression("CP0001", "T:A.B", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: true))); 163Assert.False(engine.IsErrorSuppressed(new Suppression("CP0001", "T:A.B", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: false))); 165Assert.True(engine.IsErrorSuppressed(new Suppression("CP0001", "T:A.C", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: false))); 166Assert.False(engine.IsErrorSuppressed(new Suppression("CP0001", "T:A.C", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: true))); 169engine.AddSuppression(new Suppression("CP0003", null, "ref/net6.0/myleft.dll", "lib/net6.0/myright.dll", isBaselineSuppression: false)); 171Assert.True(engine.IsErrorSuppressed(new Suppression("CP0003", "T:A.B", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll"))); 172Assert.True(engine.IsErrorSuppressed(new Suppression("CP0003", "T:A.C", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll"))); 173Assert.True(engine.IsErrorSuppressed(new Suppression("CP0003", "T:A.D", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll"))); 174Assert.False(engine.IsErrorSuppressed(new Suppression("CP0003", "T:A.D", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll", isBaselineSuppression: true))); 177engine.AddSuppression(new Suppression(string.Empty, null, "ref/net8.0/left.dll", "lib/net8.0/left.dll", isBaselineSuppression: false)); 178engine.AddSuppression(new Suppression(string.Empty, null, "ref/net8.0/left.dll", "lib/net8.0/left.dll", isBaselineSuppression: true)); 180Assert.True(engine.IsErrorSuppressed(new Suppression("CP0009", "T:A.B.C.D.E", "ref/net8.0/left.dll", "lib/net8.0/left.dll", isBaselineSuppression: false))); 181Assert.True(engine.IsErrorSuppressed(new Suppression("CP0009", "T:A.B.C.D.E", "ref/net8.0/left.dll", "lib/net8.0/left.dll", isBaselineSuppression: true))); 198Suppression newSuppression = new("CP0002", "F:MyNs.Class1.Field"); 212Assert.Equal(new Suppression("CP0001") 227Assert.True(engine.IsErrorSuppressed(new Suppression("CP0001", "T:A.B", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: true))); 228Assert.False(engine.IsErrorSuppressed(new Suppression("CP1110", "T:A.B", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: false))); 230Assert.True(engine.IsErrorSuppressed(new Suppression("CP0001", "T:A.C", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: false))); 231Assert.False(engine.IsErrorSuppressed(new Suppression("CP1000", "T:A.C", "ref/net6.0/myLib.dll", "lib/net6.0/myLib.dll", isBaselineSuppression: true))); 233Assert.True(engine.IsErrorSuppressed(new Suppression("CP0003", "T:A.B", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll"))); 234Assert.True(engine.IsErrorSuppressed(new Suppression("CP0003", "T:A.C", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll"))); 235Assert.True(engine.IsErrorSuppressed(new Suppression("CP0003", "T:A.D", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll"))); 236Assert.False(engine.IsErrorSuppressed(new Suppression("CP1232", "T:A.D", "ref/net6.0/myLeft.dll", "lib/net6.0/myRight.dll", isBaselineSuppression: true)));
Logging\SuppressionTests.cs (43)
10yield return new object[] { new Suppression(string.Empty), new Suppression(string.Empty) { Left = null, Right = null, Target = null } }; 11yield return new object[] { new Suppression(string.Empty), new Suppression(string.Empty) { Left = string.Empty, Right = string.Empty, Target = string.Empty } }; 12yield return new object[] { new Suppression("PK004"), new Suppression("pk004") }; 13yield return new object[] { new Suppression("PK004"), new Suppression(" pk004 ") }; 14yield return new object[] { new Suppression("PK004") { Target = "A.B" }, new Suppression(" pk004 ") { Target = "A.b " } }; 15yield return new object[] { new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll" }, new Suppression(" pk004 ") { Target = "A.B", Left = "ref/net6.0/mylib.dll" } }; 16yield return new object[] { new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll" }, new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = false } }; 17yield return new object[] { new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = false }, new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = false } }; 18yield return new object[] { new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = true }, new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = true } }; 23yield return new object[] { new Suppression(string.Empty), new Suppression("PK005") }; 24yield return new object[] { new Suppression("PK004"), new Suppression("PK005") }; 25yield return new object[] { new Suppression("PK004"), new Suppression("PK004") { Target = "A.B()" } }; 26yield return new object[] { new Suppression("PK004") { Target = "A.B" }, new Suppression("PK004") { Target = "A.B()" } }; 27yield return new object[] { new Suppression("PK004") { Target = "A.C" }, new Suppression("PK004") { Target = "A.B()" } }; 28yield return new object[] { new Suppression("PK004") { Target = "A.B()", Left = "ref/net6.0/myLib.dll" }, new Suppression("PK004") { Target = "A.B()" } }; 29yield return new object[] { new Suppression("PK004") { Target = "A.B()", Left = "ref/net6.0/myLib.dll" }, new Suppression("PK004") { Target = "A.B()", Left = "lib/net6.0/myLib.dll" } }; 30yield return new object[] { new Suppression("PK004") { Target = "A.B()", Right = "ref/net6.0/myLib.dll" }, new Suppression("PK004") { Target = "A.B()" } }; 31yield return new object[] { new Suppression("PK004") { Target = "A.B()", Right = "ref/net6.0/myLib.dll" }, new Suppression("PK004") { Target = "A.B()", Right = "lib/net6.0/myLib.dll" } }; 32yield return new object[] { new Suppression("PK004") { Target = "A.B()", Left = "ref/net6.0/mylib.dll", Right = "lib/net6.0/myLib.dll" }, new Suppression("PK004") { Target = "A.B()", Left = "ref/netstandard2.0/mylib.dll", Right = "lib/net6.0/myLib.dll" } }; 33yield return new object[] { new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = true }, new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = false } }; 34yield return new object[] { new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll" }, new Suppression("PK004") { Target = "A.B", Left = "ref/net6.0/myLib.dll", Right = "lib/net6.0/myLib.dll", IsBaselineSuppression = true } }; 56Assert.False(new Suppression("PK0004").Equals(null));
Microsoft.DotNet.PackageValidation (8)
ApiCompatRunnerExtensions.cs (1)
91log.LogWarning(new Suppression(DiagnosticIds.SearchDirectoriesNotFoundForTfm) { Target = displayString },
Validators\BaselinePackageValidator.cs (4)
48log.LogError(new Suppression(DiagnosticIds.TargetFrameworkDropped) { Target = baselineTargetFramework.ToString() }, 72log.LogError(new Suppression(DiagnosticIds.TargetFrameworkDropped) { Target = baselineTargetFramework.ToString() }, 101log.LogError(new Suppression(DiagnosticIds.TargetFrameworkAndRidPairDropped) { Target = baselineTargetFramework.ToString() + "-" + baselineRuntimeSpecificAssetsRidGroup.Key }, 136log.LogWarning(new Suppression(DiagnosticIds.BaselineTargetFrameworkIgnoredButPresentInCurrentPackage,
Validators\CompatibleTFMValidator.cs (3)
44log.LogError(new Suppression(DiagnosticIds.ApplicableCompileTimeAsset) { Target = framework.ToString() }, 54log.LogError(new Suppression(DiagnosticIds.CompatibleRuntimeRidLessAsset) { Target = framework.ToString() }, 74log.LogError(new Suppression(DiagnosticIds.CompatibleRuntimeRidSpecificAsset) { Target = framework.ToString() + "-" + rid },
61 references to Suppression
Microsoft.DotNet.ApiCompat.IntegrationTests (2)
SuppressibleTestLog.cs (2)
18public bool LogError(Suppression suppression, string code, string message) 28public bool LogWarning(Suppression suppression, string code, string message)
Microsoft.DotNet.ApiCompat.Task (4)
SuppressibleMSBuildLog.cs (2)
20public bool LogError(Suppression suppression, string code, string message) 32public bool LogWarning(Suppression suppression, string code, string message)
SuppressionFileHelper.cs (2)
68IReadOnlyCollection<Suppression> unnecessarySuppressions = suppressionEngine.GetUnnecessarySuppressions(); 75foreach (Suppression unnecessarySuppression in unnecessarySuppressions)
Microsoft.DotNet.ApiCompat.Tests (2)
SuppressionFileHelper.cs (2)
68IReadOnlyCollection<Suppression> unnecessarySuppressions = suppressionEngine.GetUnnecessarySuppressions(); 75foreach (Suppression unnecessarySuppression in unnecessarySuppressions)
Microsoft.DotNet.ApiCompat.Tool (4)
SuppressibleConsoleLog.cs (2)
20public bool LogError(Suppression suppression, string code, string message) 32public bool LogWarning(Suppression suppression, string code, string message)
SuppressionFileHelper.cs (2)
68IReadOnlyCollection<Suppression> unnecessarySuppressions = suppressionEngine.GetUnnecessarySuppressions(); 75foreach (Suppression unnecessarySuppression in unnecessarySuppressions)
Microsoft.DotNet.ApiCompatibility (33)
Logging\ISuppressibleLog.cs (2)
25bool LogError(Suppression suppression, string code, string message); 34bool LogWarning(Suppression suppression, string code, string message);
Logging\ISuppressionEngine.cs (10)
7/// Suppression engine that contains a collection of <see cref="Suppression"/> items. It provides API to add a suppression, check if a passed-in suppression is already suppressed 13/// If true, adds the suppression to the collection when passed into <see cref="IsErrorSuppressed(Suppression)"/>. 20IReadOnlyCollection<Suppression> BaselineSuppressions { get; } 25IReadOnlyCollection<Suppression> Suppressions { get; } 30/// <param name="suppression">The <see cref="Suppression"/> to be added.</param> 31void AddSuppression(Suppression suppression); 37IReadOnlyCollection<Suppression> GetUnnecessarySuppressions(); 42/// <param name="error">The <see cref="Suppression"/> error to check.</param> 44bool IsErrorSuppressed(Suppression error); 58(bool SuppressionFileUpdated, IReadOnlyCollection<Suppression> UpdatedSuppressions) WriteSuppressionsToFile(string suppressionOutputFile, bool preserveUnnecessarySuppressions = false);
Logging\Suppression.cs (3)
9public class Suppression : IEquatable<Suppression> 72public override bool Equals(object? obj) => Equals(obj as Suppression); 75public bool Equals(Suppression? other)
Logging\SuppressionEngine.cs (17)
10/// Suppression engine that contains a collection of <see cref="Suppression"/> items. It provides API to add a suppression, check if a passed-in suppression is already suppressed 18private readonly HashSet<Suppression> _baselineSuppressions = []; 19private readonly HashSet<Suppression> _suppressions = []; 26public IReadOnlyCollection<Suppression> BaselineSuppressions => _baselineSuppressions; 29public IReadOnlyCollection<Suppression> Suppressions => _suppressions; 40if (serializer.Deserialize(reader) is Suppression[] deserializedSuppressions) 53public bool IsErrorSuppressed(Suppression error) 70Suppression globalTargetSuppression = new(error.DiagnosticId, error.Target, isBaselineSuppression: error.IsBaselineSuppression); 73Suppression globalLeftRightSuppression = new(string.Empty, left: error.Left, right: error.Right, isBaselineSuppression: error.IsBaselineSuppression); 76Suppression globalDiagnosticIdLeftRightSuppression = new(error.DiagnosticId, left: error.Left, right: error.Right, isBaselineSuppression: error.IsBaselineSuppression); 85if (_baselineSuppressions.TryGetValue(globalTargetSuppression, out Suppression? globalSuppression) || 104public void AddSuppression(Suppression suppression) => _suppressions.Add(suppression); 107public (bool SuppressionFileUpdated, IReadOnlyCollection<Suppression> UpdatedSuppressions) 112HashSet<Suppression> suppressionsToSerialize = new(_suppressions); 125Suppression[] orderedSuppressions = suppressionsToSerialize 148public IReadOnlyCollection<Suppression> GetUnnecessarySuppressions() => _baselineSuppressions.Except(_suppressions).ToArray(); 160private static XmlSerializer CreateXmlSerializer() => new(typeof(Suppression[]), new XmlRootAttribute("Suppressions"));
Runner\ApiCompatRunner.cs (1)
68Suppression suppression = new(difference.DiagnosticId)
Microsoft.DotNet.ApiCompatibility.Tests (14)
Logging\SuppressionEngineTests.cs (7)
16Suppression suppression = new("PKG004", "A.B()", "ref/net6.0/mylib.dll", "lib/net6.0/mylib.dll"); 81IReadOnlyCollection<Suppression> unnecessarySuppressions = suppressionEngine.GetUnnecessarySuppressions(); 113Suppression usedSuppression = new("CP0001", "T:A", "lib/netstandard1.3/tempValidation.dll", "lib/netstandard1.3/tempValidation.dll"); 198Suppression newSuppression = new("CP0002", "F:MyNs.Class1.Field"); 208XmlSerializer xmlSerializer = new(typeof(Suppression[]), new XmlRootAttribute("Suppressions")); 209Suppression[] deserializedSuppressions = xmlSerializer.Deserialize(stream) as Suppression[];
Logging\SuppressionTests.cs (4)
39public void CheckSuppressionsAreEqual(Suppression suppression, Suppression other) 47public void CheckSuppressionsAreNotEqual(Suppression suppression, Suppression other)
Runner\ApiCompatRunnerTests.cs (1)
34.Setup(m => m.IsErrorSuppressed(It.IsAny<Suppression>()))
SuppressibleTestLog.cs (2)
18public bool LogError(Suppression suppression, string code, string message) 28public bool LogWarning(Suppression suppression, string code, string message)
Microsoft.DotNet.PackageValidation.Tests (2)
SuppressibleTestLog.cs (2)
18public bool LogError(Suppression suppression, string code, string message) 28public bool LogWarning(Suppression suppression, string code, string message)