Skip to content

Commit

Permalink
Restore netcoreapp1.0 support for testhost (#2554)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell authored Sep 16, 2020
1 parent 2c40f2b commit 50e6af6
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 32 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ private static Func<IDictionary<string, FrameworkVersion>, DataCollectorSettings
{
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
Original file line number Diff line number Diff line change
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.

Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static TraceLevel TraceLevel

#endif

#if NETSTANDARD2_0
#if NETSTANDARD
public static PlatformTraceLevel TraceLevel
{
get
Expand Down
Original file line number Diff line number Diff line change
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.

Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.

Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 50e6af6

Please sign in to comment.