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

Test | Removing all net5 references from the driver #1823

Merged
merged 2 commits into from
Nov 2, 2022
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 @@ -59,7 +59,7 @@ internal sealed class NotNullWhenAttribute : Attribute
}
#endif

#if !NET5_0_OR_GREATER
#if !NET6_0_OR_GREATER
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
internal sealed class MemberNotNullAttribute : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ public static bool IsAdmin
{
get
{
#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
System.Diagnostics.Debug.Assert(OperatingSystem.IsWindows());
#endif
return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void Dispose()

public static void AddKeyToCng(string providerName, string containerName)
{
#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
System.Diagnostics.Debug.Assert(OperatingSystem.IsWindows());
#endif
CngKeyCreationParameters keyParams = new CngKeyCreationParameters();
Expand All @@ -202,7 +202,7 @@ public static void AddKeyToCng(string providerName, string containerName)

public static void RemoveKeyFromCng(string providerName, string containerName)
{
#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
System.Diagnostics.Debug.Assert(OperatingSystem.IsWindows());
#endif
CngProvider cngProvider = new CngProvider(providerName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void Dispose()

public static void AddKeyToCsp(string containerName)
{
#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
System.Diagnostics.Debug.Assert(OperatingSystem.IsWindows());
#endif
CspParameters cspParams = new();
Expand All @@ -194,7 +194,7 @@ public static void AddKeyToCsp(string containerName)

public static void RemoveKeyFromCsp(string containerName)
{
#if NET5_0_OR_GREATER
#if NET6_0_OR_GREATER
System.Diagnostics.Debug.Assert(OperatingSystem.IsWindows());
#endif
CspParameters cspParams = new CspParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<RuntimeIdentifier Condition="'$(TargetGroup)'=='netfx'">win</RuntimeIdentifier>
<DefineConstants Condition="'$(TargetGroup)'=='netfx'">$(DefineConstants);NETFRAMEWORK</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);NETCOREAPP</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp' AND !$(TargetFramework.StartsWith('netcoreapp'))">$(DefineConstants);NET50_OR_LATER</DefineConstants>
<DefineConstants Condition="$(ReferenceType.Contains('NetStandard'))">NETSTANDARDREFERNCE</DefineConstants>
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)</IntermediateOutputPath>
<OutputPath>$(BinFolder)$(Configuration).$(Platform).$(AssemblyName)</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Security.Cryptography.X509Certificates;
using Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.Setup;
using Xunit;
#if NET50_OR_LATER
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif

Expand All @@ -17,7 +17,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
/// Always Encrypted public CspProvider Manual tests.
/// TODO: These tests are marked as Windows only for now but should be run for all platforms once the Master Key is accessible to this app from Azure Key Vault.
/// </summary>
#if NET50_OR_LATER
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
[PlatformSpecific(TestPlatforms.Windows)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using Xunit;
#if NET50_OR_LATER
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif

namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
{
#if NET50_OR_LATER
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
[PlatformSpecific(TestPlatforms.Windows)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1556,13 +1556,14 @@ private static void ReadStream(string connectionString)
DataTestUtility.AssertThrowsWrapper<ArgumentOutOfRangeException>(() => stream.Read(buffer, -1, 2));
DataTestUtility.AssertThrowsWrapper<ArgumentOutOfRangeException>(() => stream.Read(buffer, 2, -1));

// ArgumentException is thrown in net5 and earlier. ArgumentOutOfRangeException in net6 and later
// Prior to net6 comment:ArgumentException is thrown in net5 and earlier. ArgumentOutOfRangeException in net6 and later
// After adding net6: Running tests against netstandard2.1 still showing ArgumentException, but the rest works fine.
ArgumentException ex = Assert.ThrowsAny<ArgumentException>(() => stream.Read(buffer, buffer.Length, buffer.Length));
Assert.True(ex.GetType() == typeof(ArgumentException) || ex.GetType() == typeof(ArgumentOutOfRangeException),
"Expected: ArgumentException in net5 and earlier. ArgumentOutOfRangeException in net6 and later.");
"Expected: ArgumentException in net5 and earlier. ArgumentOutOfRangeException in net6 and later.");
ex = Assert.ThrowsAny<ArgumentException>(() => stream.Read(buffer, int.MaxValue, int.MaxValue));
Assert.True(ex.GetType() == typeof(ArgumentException) || ex.GetType() == typeof(ArgumentOutOfRangeException),
"Expected: ArgumentException in net5 and earlier. ArgumentOutOfRangeException in net6 and later.");
"Expected: ArgumentException in net5 and earlier. ArgumentOutOfRangeException in net6 and later.");
}

// Once Reader is closed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
{
#if NET50_OR_LATER
#if NET6_0_OR_GREATER
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
#endif
public class SqlDataSourceEnumeratorTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName>PerformanceTests</AssemblyName>
<TargetFrameworks>net6.0;net5.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Configurations>Debug;Release;</Configurations>
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)</IntermediateOutputPath>
Expand Down