diff --git a/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs b/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs index 0585a690e103ed..ad1e0492508749 100644 --- a/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs +++ b/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Eventing.Reader; using System.IO; using System.Reflection; @@ -12,6 +13,7 @@ namespace System.Diagnostics.Tests public class EventLogMessagesTests { [Fact] + [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The test asserts the assembly contains no types; trimming cannot make an empty assembly emptier.")] public void EventLogMessagesContainsNoTypes() { Assembly messageAssembly = Assembly.Load("System.Diagnostics.EventLog.Messages"); diff --git a/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj b/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj index d053b119d0e1f1..66b09a1a8ff65e 100644 --- a/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj +++ b/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj @@ -2,8 +2,6 @@ $(NetCoreAppCurrent)-windows;$(NetFrameworkCurrent) true - - false diff --git a/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj b/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj index 8c226e1a9895b0..edffca2836d086 100644 --- a/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj +++ b/src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj @@ -4,8 +4,6 @@ true $(MSBuildProjectDirectory)\..\src\Resources\Strings.resx true - - false diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs index 9f0dce0d70a47f..cde4fff57c5966 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading; using Xunit; @@ -17,7 +18,7 @@ public class TestSite : ISite public bool DesignMode => designMode; public IComponent Component => null; public IContainer Container => null; - public string Name { get; set; } + public string Name { get; [RequiresUnreferencedCode("The Type of components in the container cannot be statically discovered to validate the name.")] set; } public object GetService(Type serviceType) => null; } diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs index 4314360f24d6e1..46ff00aa18374c 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs @@ -289,7 +289,7 @@ public void FileSystemWatcher_NotifyFilter() FileSystemWatcher watcher = new FileSystemWatcher(); Assert.Equal(NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName, watcher.NotifyFilter); - var notifyFilters = Enum.GetValues(typeof(NotifyFilters)).Cast(); + var notifyFilters = Enum.GetValues(); foreach (NotifyFilters filterValue in notifyFilters) { watcher.NotifyFilter = filterValue; diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj index 0fd33d637cee22..1e43fca4491b34 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj @@ -4,9 +4,6 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-freebsd true - - false - false diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs index f56d2981f54f71..76998c32d01e39 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs @@ -465,7 +465,7 @@ public static bool TryErrorEvent(FileSystemWatcher watcher, Action action, Actio public static IEnumerable FilterTypes() { - foreach (NotifyFilters filter in Enum.GetValues(typeof(NotifyFilters))) + foreach (NotifyFilters filter in Enum.GetValues()) yield return new object[] { filter }; } diff --git a/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs b/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs index 71eed3a8b16e9d..28af6e83750d12 100644 --- a/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs +++ b/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs @@ -3,11 +3,13 @@ using System.Buffers.Binary; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using Xunit; namespace System.IO.Hashing.Tests { + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] public abstract class NonCryptoHashTestDriver { private readonly int _hashLengthInBytes; diff --git a/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj b/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj index 30c787d6679464..81e5ede74483d1 100644 --- a/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj +++ b/src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj @@ -3,8 +3,6 @@ true $(NetCoreAppCurrent);$(NetFrameworkCurrent) - - false @@ -36,6 +34,12 @@ + + + + + + diff --git a/src/libraries/System.Runtime/tests/System.IO.Tests/System.IO.Tests.csproj b/src/libraries/System.Runtime/tests/System.IO.Tests/System.IO.Tests.csproj index 58e6e57345a8be..ebb8cdcd4db80e 100644 --- a/src/libraries/System.Runtime/tests/System.IO.Tests/System.IO.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.IO.Tests/System.IO.Tests.csproj @@ -6,8 +6,6 @@ true $(NetCoreAppCurrent) true - - false 1 diff --git a/src/libraries/System.Runtime/tests/System.IO.Tests/TextWriter/TextWriterTests.cs b/src/libraries/System.Runtime/tests/System.IO.Tests/TextWriter/TextWriterTests.cs index 93da43eeb0c7b4..41cf90821b1a92 100644 --- a/src/libraries/System.Runtime/tests/System.IO.Tests/TextWriter/TextWriterTests.cs +++ b/src/libraries/System.Runtime/tests/System.IO.Tests/TextWriter/TextWriterTests.cs @@ -4,6 +4,7 @@ using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Reflection; @@ -1049,6 +1050,7 @@ public async Task CreateBroadcasting_DelegatesToAllWriters() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] + [UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Test is skipped under trimming via IsNotBuiltWithAggressiveTrimming.")] public void CreateBroadcasting_AllMethodsOverridden() { HashSet exempted = ["Close", "Dispose", "get_NewLine", "set_NewLine"];