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

Replace NET451 compiler directives with NETFRAMEWORK #2516

Merged
3 commits merged into from
Aug 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework
{
#if NET451
#if NETFRAMEWORK
using System.Threading;
#endif
using System;
Expand Down Expand Up @@ -196,7 +196,7 @@ public Dictionary<string, TPluginInfo> DiscoverTestExtensions<TPluginInfo, TExte

this.LogExtensions();
}
#if NET451
#if NETFRAMEWORK
catch (ThreadAbortException)
{
// Nothing to do here, we just do not want to do an EqtTrace.Fail for this thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static T CreateTestExtension<T>(Type extensionType)
}
throw;
}
#if NET451
#if NETFRAMEWORK
else if (ex is SystemException)
{
if (EqtTrace.IsErrorEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Logging
using System.Collections.ObjectModel;
using System.Diagnostics;

#if NET451
#if NETFRAMEWORK
using System.Configuration;
#endif

Expand Down Expand Up @@ -398,7 +398,7 @@ private int GetMaxBytesQueueCanHold()
private static bool IsBoundsEnabledOnLoggerEventQueue()
{
bool enableBounds;
#if NET451
#if NETFRAMEWORK
string enableBoundsOnEventQueueIsDefined = ConfigurationManager.AppSettings[TestPlatformDefaults.EnableBoundsOnLoggerEventQueue];
#else
string enableBoundsOnEventQueueIsDefined = null;
Expand Down Expand Up @@ -444,7 +444,7 @@ private static int FindTestResultSize(TestResultEventArgs args)
private int GetSetting(string appSettingKey, int defaultValue)
{
int value;
#if NET451
#if NETFRAMEWORK
string appSettingValue = ConfigurationManager.AppSettings[appSettingKey];
#else
string appSettingValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set

private static Func<IEnumerable<string>, string> TryGetNetFrameworkFakesDataCollectorConfigurator()
{
#if NET451
#if NETFRAMEWORK
try
{
Assembly assembly = Assembly.Load(FakesConfiguratorAssembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private static XmlDocument GetRunSettingXmlDocument(this IRunSettingsProvider ru
{
var settingsXml = runSettingsProvider.ActiveRunSettings.SettingsXml;

#if NET451
#if NETFRAMEWORK
using (var reader = XmlReader.Create(new StringReader(settingsXml), new XmlReaderSettings() { XmlResolver = null, CloseInput = true, DtdProcessing = DtdProcessing.Prohibit }))
{
#else
Expand All @@ -240,7 +240,7 @@ private static XmlDocument GetRunSettingXmlDocument(this IRunSettingsProvider ru
}
else
{
#if NET451
#if NETFRAMEWORK
doc = (XmlDocument) XmlRunSettingsUtilities.CreateDefaultRunSettings();
#else
using (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void Stop(Exception error)
this.stopped = true;

// Close the client and dispose the underlying stream
#if NET451
#if NETFRAMEWORK
// tcpClient.Close() calls tcpClient.Dispose().
this.tcpClient?.Close();
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public bool WaitForServerConnection(int connectionTimeout)
/// </summary>
public void StopClient()
{
#if NET451
#if NETFRAMEWORK
// tcpClient.Close() calls tcpClient.Dispose().
this.tcpClient?.Close();
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void Stop(Exception error)
this.tcpListener.Stop();

// Close the client and dispose the underlying stream
#if NET451
#if NETFRAMEWORK
// tcpClient.Close() calls tcpClient.Dispose().
this.tcpClient?.Close();
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class EqtTrace
{
private static IPlatformEqtTrace traceImpl = new PlatformEqtTrace();

#if NET451
#if NETFRAMEWORK
public static void SetupRemoteEqtTraceListeners(AppDomain childDomain)
{
traceImpl.SetupRemoteEqtTraceListeners(childDomain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter
/// Exception thrown on parsing error in user provided filter expression.
/// This can happen when filter has invalid format or has unsupported properties.
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
public class TestPlatformFormatException : Exception
Expand Down Expand Up @@ -55,7 +55,7 @@ public TestPlatformFormatException(string message, Exception innerException)
{
}

#if NET451
#if NETFRAMEWORK
/// <summary>
/// Serialization constructor.
/// </summary>
Expand All @@ -79,7 +79,7 @@ public string FilterValue
private set;
}

#if NET451
#if NETFRAMEWORK
/// <summary>
/// Serialization helper.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter
{
using System;

#if NET451
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif

/// <summary>
/// Exception thrown by the framework when an executor attempts to send
/// test result to the framework when the test is canceled.
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
public class TestCanceledException : Exception
Expand Down Expand Up @@ -46,7 +46,7 @@ public TestCanceledException(string message, Exception innerException)
{
}

#if NET451
#if NETFRAMEWORK
/// <summary>
/// Serialization constructor.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.TestPlatform.ObjectModel/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static class Constants
/// The default execution thread apartment state.
/// </summary>
[CLSCompliant(false)]
#if NET451
#if NETFRAMEWORK
// Keeping default STA thread for desktop tests for UI/Functional test scenarios
public static readonly PlatformApartmentState DefaultExecutionThreadApartmentState = PlatformApartmentState.STA;
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection
{
#if NET451
#if NETFRAMEWORK
using System;
#endif

/// <summary>
/// Encapsulates the context of the environment a data collector is being hosted in.
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
public sealed class DataCollectionEnvironmentContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection
/// <summary>
/// Base class for all execution event arguments
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
public abstract class DataCollectionEventArgs : EventArgs
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.TestPlatform.ObjectModel/ExceptionConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
/// <summary>
/// Base exception for all Rocksteady service exceptions
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")]
Expand Down Expand Up @@ -96,7 +96,7 @@ private static Exception ConvertException(String exceptionType, String message,
}
#endif

#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")]
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.TestPlatform.ObjectModel/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
/// </summary>
public class Framework
{
#if NET451
#if NETFRAMEWORK
private static readonly Framework Default = Framework.FromString(".NETFramework,Version=v4.0");
#else
private static readonly Framework Default = Framework.FromString(".NETCoreApp,Version=v1.0");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if NET451
#if NETFRAMEWORK

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
{
using System;
#if NET451
#if NETFRAMEWORK
using System.Runtime.Serialization;
#endif

Expand All @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
/// Exception thrown by Run Settings when an error with a settings provider
/// is encountered.
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
public class SettingsException : Exception
Expand Down Expand Up @@ -46,7 +46,7 @@ public SettingsException(string message, Exception innerException)
{
}

#if NET451
#if NETFRAMEWORK
/// <summary>
/// Serialization constructor.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.TestPlatform.ObjectModel/Trait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
{
#if NET451
#if NETFRAMEWORK
using System;
#endif
using System.Collections.Generic;
Expand All @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
/// Class that holds Trait.
/// A traits is Name, Value pair.
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
[DataContract]
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.TestPlatform.ObjectModel/TraitCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
/// <summary>
/// Class that holds collection of traits
/// </summary>
#if NET451
#if NETFRAMEWORK
[Serializable]
#endif
public class TraitCollection : IEnumerable<Trait>
Expand All @@ -33,7 +33,7 @@ public class TraitCollection : IEnumerable<Trait>
#pragma warning restore 618
typeof(TestObject));

#if NET451
#if NETFRAMEWORK
[NonSerialized]
#endif
private readonly TestObject testObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities
{
#if NET451
#if NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities
{
#if NET451
#if NETFRAMEWORK
using System;
using System.Diagnostics;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities
{
#if NET451
#if NETFRAMEWORK
using System;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Utilities
{
using System;
using System.Diagnostics.CodeAnalysis;
#if NET451
#if NETFRAMEWORK
using System.Security;
#endif
using System.Xml;
Expand Down Expand Up @@ -62,7 +62,7 @@ internal static void AppendOrModifyChild(

// TODO: There isn't an equivalent API to SecurityElement.Escape in Core yet.
// So trusting that the XML is always valid for now.
#if NET451
#if NETFRAMEWORK
var secureInnerXml = SecurityElement.Escape(innerXml);
#else
// fixing manually as we currently target to netcore 1.1 and we don't have default implementation for Escape functionality
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer
{
using System;
#if NET451
#if NETFRAMEWORK
using System.Collections.Generic;
#endif
using System.Diagnostics;
Expand Down Expand Up @@ -40,7 +40,7 @@ public ConsoleParameters(IFileHelper fileHelper)
this.fileHelper = fileHelper;
}

#if NET451
#if NETFRAMEWORK

/// <summary>
/// TODO: Remove the #if when project is targeted to netstandard2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void StartProcess(ConsoleParameters consoleParameters)

EqtTrace.Verbose("VsTestCommandLineWrapper: Process Start Info {0} {1}", info.FileName, info.Arguments);

#if NET451
#if NETFRAMEWORK
if (consoleParameters.EnvironmentVariables != null)
{
info.EnvironmentVariables.Clear();
Expand Down
2 changes: 1 addition & 1 deletion src/testhost.x86/AppDomainEngineInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.VisualStudio.TestPlatform.TestHost
{
#if NET451
#if NETFRAMEWORK
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing;

Expand Down
Loading