Skip to content

Commit fa2c19f

Browse files
Fix analyzer warnings in Windows library tests
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/5e49e977-7ef9-4b3f-ba25-f076d020cb7e Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
1 parent ef691cd commit fa2c19f

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/libraries/System.DirectoryServices/tests/System/DirectoryServices/DirectoryServicesTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Runtime.InteropServices;
5-
using System.Collections.Generic;
64
using System.Collections;
5+
using System.Collections.Generic;
6+
using System.Reflection;
7+
using System.Runtime.InteropServices;
78
using Xunit;
89
using Xunit.Sdk;
9-
using System.Reflection;
1010

1111
namespace System.DirectoryServices.Tests
1212
{
@@ -18,7 +18,9 @@ public partial class DirectoryServicesTests
1818
[Fact]
1919
public void TestGetAllTypes()
2020
{
21+
#pragma warning disable IL2026 // Test validates Assembly.GetTypes in an untrimmed test build.
2122
Type[] allTypes = typeof(DirectoryEntry).Assembly.GetTypes();
23+
#pragma warning restore IL2026
2224
Assert.Contains(typeof(DirectoryEntry), allTypes);
2325
}
2426

src/libraries/System.Management/tests/System/Management/ManagementObjectTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Diagnostics;
5+
using System.Diagnostics.CodeAnalysis;
56
using System.IO;
67
using System.Runtime.Serialization.Formatters.Binary;
78
using Microsoft.DotNet.XUnitExtensions;
@@ -105,6 +106,10 @@ public void Invoke_Instance_And_Static_Method_Win32_Process()
105106
[ConditionalFact(typeof(WmiTestHelper), nameof(WmiTestHelper.IsWmiSupported))]
106107
[ActiveIssue("https://github.com/dotnet/runtime/issues/34689", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
107108
[OuterLoop]
109+
#if NET
110+
[RequiresDynamicCode("BinaryFormatter serialization uses dynamic code generation")]
111+
[RequiresUnreferencedCode("BinaryFormatter serialization is not trim compatible")]
112+
#endif
108113
public void Serialize_ManagementException()
109114
{
110115
try

0 commit comments

Comments
 (0)