Skip to content

Commit

Permalink
Fix SYSLIB obsoletion warnings in tests (dotnet#51847)
Browse files Browse the repository at this point in the history
* Fix SYSLIB obsoletion warnings in tests

* Simplify references to assembly location
  • Loading branch information
jeffhandley authored Apr 26, 2021
1 parent 7b575d7 commit 0fc2afa
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/tests/Common/dir.sdkbuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<EnableDefaultItems>false</EnableDefaultItems>
<Platform>AnyCPU</Platform>
<NoWarn>$(NoWarn),618,SYSLIB0012</NoWarn>

<!-- [ARCADE REMOVE] This line should be removed we use the Arcade Sdk. -->
<DeterministicSourcePaths>false</DeterministicSourcePaths>
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<!-- Disable some C# warnings for the tests. -->
<NoWarn>78,162,164,168,169,219,251,252,414,429,618,642,649,652,659,675,1691,1717,1718,3001,3002,3003,3005,3008,SYSLIB0004,SYSLIB0011,SYSLIB0012</NoWarn>
<NoWarn>78,162,164,168,169,219,251,252,414,429,618,642,649,652,659,675,1691,1717,1718,3001,3002,3003,3005,3008</NoWarn>
<RunAnalyzers>false</RunAnalyzers>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SkipSigning Condition="'$(CrossGen)' == 'true'">true</SkipSigning>
Expand Down
1 change: 0 additions & 1 deletion src/tests/GC/Performance/Tests/LowLatencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public void DoTest(int count, GCLatencyMode gcMode)
{
GCLatencyMode oldMode = GCSettings.LatencyMode;

RuntimeHelpers.PrepareConstrainedRegions();
try
{
// Load Data
Expand Down
3 changes: 3 additions & 0 deletions src/tests/GC/Stress/Framework/LoaderClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void SuppressConsole()
Console.SetOut(System.IO.TextWriter.Null);
}

#pragma warning disable SYSLIB0012 // Assembly.CodeBase is obsolete

/// <summary>
/// Executes a LoadFrom in the app domain LoaderClass has been loaded into. Attempts to load a given assembly, looking in the
/// given paths & the current directory.
Expand Down Expand Up @@ -122,6 +124,7 @@ public void LoadFrom(string path, string[] paths
}
}
}
#pragma warning restore SYSLIB0012

/// <summary>
/// Attempts to load an assembly w/ a simple name, looking in the given paths if a normal load fails
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Interop/COM/NETClients/Primitives/TestInALC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Test
{
static int Main(string[] args)
{
string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
string currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "NETClientPrimitives.dll");
return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void ConflictingCustomMarshalerNamesInNoncollectibleLoadContexts_Succeeds

static void Run(AssemblyLoadContext context)
{
string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
string currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Assembly inContextAssembly = context.LoadFromAssemblyPath(Path.Combine(currentAssemblyDirectory, "CustomMarshaler.dll"));
Type inContextType = inContextAssembly.GetType("CustomMarshalers.CustomMarshalerTest");
object instance = Activator.CreateInstance(inContextType);
Expand All @@ -54,7 +54,7 @@ class UnloadableLoadContext : AssemblyLoadContext
public UnloadableLoadContext()
:base(true)
{

}

protected override Assembly Load(AssemblyName assemblyName)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Interop/MarshalAPI/IUnknown/TestInALC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Test
{
static int Main(string[] args)
{
string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
string currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "IUnknownTest.dll");
return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Test
{
static int Main(string[] args)
{
string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
string currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "DefaultTest.dll");
return TestLibrary.Utilities.ExecuteAndUnload(testAssemblyFullPath, args);
}
Expand Down
2 changes: 2 additions & 0 deletions src/tests/JIT/Regression/JitBlue/GitHub_25468/GitHub_25468.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Regressions/coreclr/GitHub_22888/test22888.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static bool LoadAndUnload(string assemblyPath, out WeakReference alcWeakRef)

public static int Main()
{
string currentAssemblyDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
string currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string testAssemblyFullPath = Path.Combine(currentAssemblyDirectory, "test22888resources.dll");

WeakReference alcWeakRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public static void Run()
int val = 21;
try
{
#pragma warning disable SYSLIB0004 // CER is obsolete
RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(t, c, val);
#pragma warning restore SYSLIB0004
}
catch (Exception Ex)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/run.proj
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\","").
static _Global()
{
reportBase = System.Environment.GetEnvironmentVariable(%22XunitTestReportDirBase%22)%3B
testBinaryBase = System.IO.Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)%3B
testBinaryBase = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)%3B
coreRoot = System.Environment.GetEnvironmentVariable(%22CORE_ROOT%22)%3B
category = "$([System.String]::Copy($(Category)).Replace(".","_").Replace("\","").Replace("-","_"))"%3B
Expand Down

0 comments on commit 0fc2afa

Please sign in to comment.