Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore netcoreapp1.0 support for testhost #2554

Merged
1 commit merged into from Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -81,7 +81,7 @@ private static string GetExtensionUri(Type testLoggerType)

if (EqtTrace.IsErrorEnabled && string.IsNullOrEmpty(extensionUri))
{
EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.Module.Name);
EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.GetTypeInfo().Module.Name);
}

return extensionUri;
Expand Down
Expand Up @@ -6,8 +6,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.VisualStudio.TestPlatform.Common</AssemblyName>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.3;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs
Expand Up @@ -242,8 +242,8 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set
{
try
{
Assembly assembly = Assembly.Load(FakesConfiguratorAssembly);
var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false);
Assembly assembly = Assembly.Load(new AssemblyName(FakesConfiguratorAssembly));
var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false, false);
var method = type?.GetMethod(CrossPlatformConfiguratorMethodName, new Type[] { typeof(IDictionary<string, FrameworkVersion>) });
if (method != null)
{
Expand Down
Expand Up @@ -5,8 +5,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.TestPlatform.CommunicationUtilities</AssemblyName>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.3;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>
<EnableCodeAnalysis>true</EnableCodeAnalysis>
</PropertyGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -6,8 +6,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.TestPlatform.CoreUtilities</AssemblyName>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.3;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Resources.resx" />
Expand All @@ -20,7 +20,7 @@
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup Condition=" '$(TargetFramework)' != 'net451' ">
<PackageReference Include="System.Diagnostics.FileVersionInfo">
<Version>4.0.0</Version>
</PackageReference>
Expand Down
Expand Up @@ -50,7 +50,7 @@ public static TraceLevel TraceLevel

#endif

#if NETSTANDARD2_0
#if NETSTANDARD
public static PlatformTraceLevel TraceLevel
{
get
Expand Down
Expand Up @@ -6,8 +6,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.TestPlatform.CrossPlatEngine</AssemblyName>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.3;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>
<!--<EnableCodeAnalysis>true</EnableCodeAnalysis>-->
</PropertyGroup>
Expand All @@ -26,6 +26,9 @@
<FromP2P>true</FromP2P>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Diagnostics.Process" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="System.Runtime" />
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -6,8 +6,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.VisualStudio.TestPlatform.ObjectModel</AssemblyName>
<TargetFrameworks>net451;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks>net451;netstandard2.0;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3</TargetFrameworks>
<PackageId>Microsoft.TestPlatform.ObjectModel</PackageId>
</PropertyGroup>
<ItemGroup>
Expand All @@ -31,10 +31,21 @@
<ProjectReference Include="..\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.ComponentModel.EventBasedAsync" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.ComponentModel.TypeConverter" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Json" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlDocument" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.Xml.XPath" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Condition="'$(TargetFramework)' == 'netstandard1.3'" Version="4.3.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="NuGet.Frameworks" Version="4.6.4" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.3' ">
<PackageReference Include="NuGet.Frameworks" Version="$(NuGetFrameworksVersion)" />
<PackageReference Include="System.Reflection.Metadata">
<Version>1.6.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Update="Resources\CommonResources.Designer.cs">
Expand Down
Expand Up @@ -101,8 +101,13 @@ private void PopulateCacheForTypeAndMethodSymbols(string binaryPath)
}
catch (FileNotFoundException)
{
#if !NETSTANDARD1_3
// fallback when the assembly is not loaded
asm = Assembly.LoadFile(binaryPath);
#else
// fallback is not supported
throw;
#endif
}

foreach (var type in asm.GetTypes())
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -6,8 +6,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.TestPlatform.PlatformAbstractions</AssemblyName>
<TargetFrameworks>netcoreapp2.1;net451;uap10.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;net451;uap10.0;netstandard2.0;netstandard1.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.0;netcoreapp2.1</TargetFrameworks>
<EnableCodeAnalysis>true</EnableCodeAnalysis>
<NoWarn>NU1605</NoWarn>
</PropertyGroup>
Expand Down
12 changes: 11 additions & 1 deletion src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs
Expand Up @@ -715,11 +715,21 @@ private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architec
{
return false;
}
if (targetPlatform == Architecture.X64 && !Environment.Is64BitOperatingSystem)
if (targetPlatform == Architecture.X64 && !Is64BitOperatingSystem())
{
return true;
}
return sourcePlatform != targetPlatform;

bool Is64BitOperatingSystem()
{
#if !NETSTANDARD1_3
return Environment.Is64BitOperatingSystem;
#else
// In the absence of APIs to check, assume the majority case
return true;
#endif
}
}

/// <summary>
Expand Down
Expand Up @@ -6,8 +6,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.TestPlatform.Utilities</AssemblyName>
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.3;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Resources.resx" />
Expand Down
18 changes: 18 additions & 0 deletions src/testhost.x86/TestHostTraceListener.cs
Expand Up @@ -76,7 +76,21 @@ public static void ShowDialog(string stackTrace, string message, string detailMe
private static DebugAssertException GetException(string message)
{
var debugTypes = new Type[] { typeof(Debug), typeof(Trace) };
#if NETCOREAPP1_0
Exception exceptionForStack;
try
{
throw new Exception();
}
catch (Exception e)
{
exceptionForStack = e;
}

var stack = new StackTrace(exceptionForStack, true);
#else
var stack = new StackTrace(true);
#endif

var debugMethodFound = false;
var frameCount = 0;
Expand All @@ -97,7 +111,11 @@ private static DebugAssertException GetException(string message)
}
}

#if NETCOREAPP1_0
var stackTrace = string.Join(Environment.NewLine, stack.ToString().Replace(Environment.NewLine, "\n").Split('\n').Reverse().Take(frameCount).Reverse());
#else
var stackTrace = string.Join(Environment.NewLine, stack.ToString().Split(Environment.NewLine).TakeLast(frameCount));
#endif
var methodName = method != null ? $"{method.DeclaringType.Name}.{method.Name}" : "<method>";
var wholeMessage = $"Method {methodName} failed with '{message}', and was translated to { typeof(DebugAssertException).FullName } to avoid terminating the process hosting the test.";

Expand Down
8 changes: 6 additions & 2 deletions src/testhost.x86/testhost.x86.csproj
Expand Up @@ -6,8 +6,8 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>testhost.x86</AssemblyName>
<TargetFrameworks>netcoreapp2.1;net451;net452;net46;net461;net462;net47;net471;net472;net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp1.0;net451;net452;net46;net461;net462;net47;net471;net472;net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netcoreapp2.1;netcoreapp1.0</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
Expand All @@ -19,6 +19,10 @@
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Diagnostics.StackTrace" Condition="'$(TargetFramework)' == 'netcoreapp1.0'" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Condition="'$(TargetFramework)' == 'netcoreapp1.0'" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.TestPlatform.CommunicationUtilities\Microsoft.TestPlatform.CommunicationUtilities.csproj" />
<ProjectReference Include="..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
Expand Down
10 changes: 7 additions & 3 deletions src/testhost/testhost.csproj
Expand Up @@ -6,12 +6,12 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>testhost</AssemblyName>
<TargetFrameworks>netcoreapp2.1;net451;net452;net46;net461;net462;net47;net471;net472;net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp1.0;net451;net452;net46;net461;net462;net47;net471;net472;net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netcoreapp2.1;netcoreapp1.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1' ">
<PropertyGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1' AND '$(TargetFramework)' != 'netcoreapp1.0'">
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
Expand All @@ -21,6 +21,10 @@
<Compile Include="..\testhost.x86\TestHostTraceListener.cs" Link="TestHostTraceListener.cs" />
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Diagnostics.StackTrace" Condition="'$(TargetFramework)' == 'netcoreapp1.0'" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Condition="'$(TargetFramework)' == 'netcoreapp1.0'" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.TestPlatform.CommunicationUtilities\Microsoft.TestPlatform.CommunicationUtilities.csproj" />
<ProjectReference Include="..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
Expand Down