Fix netcoreapp2.0 use in TestUtilities

The Roslyn code base defaults to enabling the
`<DisableImplicitFrameworkReferences>` property and instead specifies manual
references. This is mostly an artifact of our code base evolution from
the project.json days where implicit references weren't an option.

This means that even though TestUtilities specified netcoreapp2.0 as a
TF it was still mostly targeting netstandard1.3. This is because
implicit references weren't expanded and we were manually adding only a
subset of the available packages.

Enabled implicit references here, conditioned the explicit ones to
netstandard1.3 and now we can remove a number of `#if` uses.

closes #25228
上级 04787d69
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// The use of SigningTestHelpers makes this necessary for now. Fix is tracked by https://github.com/dotnet/roslyn/issues/25228
#if NET461
using System; using System;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.IO; using System.IO;
...@@ -163,4 +161,3 @@ class C ...@@ -163,4 +161,3 @@ class C
} }
} }
} }
#endif
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if NET461 || NET46 || NETCOREAPP2_0 #if !NETSTANDARD1_3
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
...@@ -542,14 +542,10 @@ static private void AppendFieldInfo(FieldInfo field, StringBuilder sb) ...@@ -542,14 +542,10 @@ static private void AppendFieldInfo(FieldInfo field, StringBuilder sb)
if (field.IsInitOnly) sb.Append("initonly "); if (field.IsInitOnly) sb.Append("initonly ");
if (field.IsLiteral) sb.Append("literal "); if (field.IsLiteral) sb.Append("literal ");
#if NET46 || NET461
if (field.IsNotSerialized) sb.Append("notserialized "); if (field.IsNotSerialized) sb.Append("notserialized ");
#endif
if (field.Attributes.HasFlag(FieldAttributes.SpecialName)) sb.Append("specialname "); if (field.Attributes.HasFlag(FieldAttributes.SpecialName)) sb.Append("specialname ");
if (field.Attributes.HasFlag(FieldAttributes.RTSpecialName)) sb.Append("rtspecialname "); if (field.Attributes.HasFlag(FieldAttributes.RTSpecialName)) sb.Append("rtspecialname ");
#if NET46 || NET461
if (field.IsPinvokeImpl) sb.Append("pinvokeimpl "); if (field.IsPinvokeImpl) sb.Append("pinvokeimpl ");
#endif
sb.Append(field.IsStatic ? "static " : "instance "); sb.Append(field.IsStatic ? "static " : "instance ");
AppendType(field.FieldType, sb); AppendType(field.FieldType, sb);
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if NET461 || NET46 #if !NETSTANDARD1_3
using System; using System;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.IO; using System.IO;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<DefineConstants>$(DefineConstants);DNX</DefineConstants> <DefineConstants>$(DefineConstants);DNX</DefineConstants>
<NoStdLib>true</NoStdLib> <NoStdLib>true</NoStdLib>
<RootNamespace></RootNamespace> <RootNamespace></RootNamespace>
<DisableImplicitFrameworkReferences>false</DisableImplicitFrameworkReferences>
</PropertyGroup> </PropertyGroup>
<ItemGroup Label="Project References"> <ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Compilers\Test\Resources\Core\CompilerTestResources.csproj" /> <ProjectReference Include="..\..\..\Compilers\Test\Resources\Core\CompilerTestResources.csproj" />
...@@ -95,36 +96,15 @@ ...@@ -95,36 +96,15 @@
<PackageReference Include="Microsoft.DiaSymReader.Converter.Xml" Version="$(MicrosoftDiaSymReaderConverterXmlVersion)" /> <PackageReference Include="Microsoft.DiaSymReader.Converter.Xml" Version="$(MicrosoftDiaSymReaderConverterXmlVersion)" />
<PackageReference Include="Microsoft.Metadata.Visualizer" Version="$(MicrosoftMetadataVisualizerVersion)" /> <PackageReference Include="Microsoft.Metadata.Visualizer" Version="$(MicrosoftMetadataVisualizerVersion)" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="$(MicrosoftNETCorePlatformsVersion)" /> <PackageReference Include="Microsoft.NETCore.Platforms" Version="$(MicrosoftNETCorePlatformsVersion)" />
<PackageReference Include="Microsoft.Win32.Primitives" Version="$(MicrosoftWin32PrimitivesVersion)" /> <PackageReference Include="xunit" Version="$(xunitVersion)" />
<PackageReference Include="System.AppContext" Version="$(SystemAppContextVersion)" /> <PackageReference Include="xunit.analyzers" Version="$(xunitanalyzersVersion)" />
<PackageReference Include="System.Collections.Concurrent" Version="$(SystemCollectionsConcurrentVersion)" /> <PackageReference Include="xunit.runner.console" Version="$(xunitrunnerconsoleVersion)" />
<PackageReference Include="System.Console" Version="$(SystemConsoleVersion)" /> </ItemGroup>
<PackageReference Include="System.Data.Common" Version="$(SystemDataCommonVersion)" /> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Diagnostics.Debug" Version="$(SystemDiagnosticsDebugVersion)" /> <PackageReference Include="System.Reflection.TypeExtensions" Version="$(SystemReflectionTypeExtensionsVersion)" />
<PackageReference Include="System.Diagnostics.Tools" Version="$(SystemDiagnosticsToolsVersion)" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="$(SystemDiagnosticsTraceSourceVersion)" /> <PackageReference Include="System.Diagnostics.TraceSource" Version="$(SystemDiagnosticsTraceSourceVersion)" />
<PackageReference Include="System.Diagnostics.Process" Version="$(SystemDiagnosticsProcessVersion)" /> <PackageReference Include="System.Diagnostics.Process" Version="$(SystemDiagnosticsProcessVersion)" />
<PackageReference Include="System.IO.FileSystem" Version="$(SystemIOFileSystemVersion)" />
<PackageReference Include="System.Net.Primitives" Version="$(SystemNetPrimitivesVersion)" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="$(SystemReflectionTypeExtensionsVersion)" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="$(SystemSecurityCryptographyAlgorithmsVersion)" />
<PackageReference Include="System.Text.RegularExpressions" Version="$(SystemTextRegularExpressionsVersion)" />
<PackageReference Include="System.Threading.Thread" Version="$(SystemThreadingThreadVersion)" /> <PackageReference Include="System.Threading.Thread" Version="$(SystemThreadingThreadVersion)" />
<PackageReference Include="System.Xml.XDocument" Version="$(SystemXmlXDocumentVersion)" />
<PackageReference Include="System.Xml.XmlDocument" Version="$(SystemXmlXmlDocumentVersion)" /> <PackageReference Include="System.Xml.XmlDocument" Version="$(SystemXmlXmlDocumentVersion)" />
<PackageReference Include="System.Runtime.Loader" Version="$(SystemRuntimeLoaderVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
<PackageReference Include="xunit" Version="$(xunitVersion)" />
<PackageReference Include="xunit.analyzers" Version="$(xunitanalyzersVersion)" />
<PackageReference Include="xunit.runner.console" Version="$(xunitrunnerconsoleVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(xunitrunnervisualstudioVersion)" />
<!-- This reference is necessary to pull down the assemblies we compile + run against
in the compiler layer when running on CoreClr. Don't actually want to reference
anything here, just have it available -->
<PackageReference Include="NETStandard.Library" Version="$(NETStandardLibraryFixedVersion)" Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PrivateAssets>all</PrivateAssets>
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
</ItemGroup> </ItemGroup>
<ProjectExtensions />
</Project> </Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册