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

Add | Adding net8 support #2230

Merged
merged 12 commits into from
Jan 12, 2024
8 changes: 4 additions & 4 deletions BUILDGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ msbuild -t:RunTests -p:configuration=Release -p:DotnetPath=C:\net6-win-x86\
To specify custom target framework, use `TF` property:

```bash
msbuild -t:RunTests -p:configuration=Release -p:TF=net7.0
msbuild -t:RunTests -p:configuration=Release -p:TF=net8.0
msbuild -t:RunTests -p:configuration=Release -p:TF=net48
# Runs tests for specified target framework.
# TargetNetCoreVersion and TargetNetFxVersion are not to be used with TF property, they will take precedence over TF if provided.
Expand Down Expand Up @@ -293,7 +293,7 @@ msbuild -t:BuildTestsNetFx -p:TargetNetFxVersion=net462
```bash
msbuild -t:BuildTestsNetCore -p:TargetNetCoreVersion=net6.0
# Build the tests for custom TargetFramework (.NET)
# Applicable values: net6.0 | net7.0
# Applicable values: net6.0 | net8.0
```

### Running Tests with custom target framework (traditional)
Expand All @@ -305,7 +305,7 @@ dotnet test -p:TargetNetFxVersion=net462 ...

dotnet test -p:TargetNetCoreVersion=net6.0 ...
# Use above property to run Functional Tests with custom TargetFramework (.NET)
# Applicable values: net6.0 | net7.0
# Applicable values: net6.0 | net8.0
```

## Using Managed SNI on Windows
Expand Down Expand Up @@ -389,7 +389,7 @@ Configure `runnerconfig.json` file with connection string and preferred settings

```bash
cd src\Microsoft.Data.SqlClient\tests\PerformanceTests
dotnet run -c Release -f net6.0|net7.0
dotnet run -c Release -f net6.0|net8.0
```

_Only "**Release** Configuration" applies to Performance Tests_
42 changes: 21 additions & 21 deletions RunPackageReferenceTests.cmd

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions RunProjectReferenceTests.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set netcoreVersion=net6.0

:: Accept two parameters for .NET Framework and .NET versions.
:: Examples:
:: - uses net48 and net7.0:
:: > RunProjectReferenceTests.cmd net48 net7.0
:: - uses net48 and net8.0:
:: > RunProjectReferenceTests.cmd net48 net8.0
:: - uses default target frameworks:
:: > RunProjectReferenceTests.cmd
:: - uses net48 and default target frameworks for netcore:
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Data.SqlClient/add-ons/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<Otherwise>
<PropertyGroup>
<TargetFrameworks Condition="'$(TestTargetOS)' == 'Windowsnetstandard' OR '$(TestTargetOS)' == 'Unixnetstandard'">netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(TestTargetOS)' == 'Windowsnetcoreapp' OR '$(TestTargetOS)' == 'Unixnetcoreapp'">net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TestTargetOS)' == 'Windowsnetcoreapp' OR '$(TestTargetOS)' == 'Unixnetcoreapp'">net6.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TestTargetOS)' == 'Windowsnetfx'">net462</TargetFrameworks>
</PropertyGroup>
</Otherwise>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,9 +1443,13 @@ internal SqlException() { }
public override string Source { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlException.xml' path='docs/members[@name="SqlException"]/State/*'/>
public byte State { get { throw null; } }

/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlException.xml' path='docs/members[@name="SqlException"]/GetObjectData/*'/>
#if !NET6_0_OR_GREATER
[System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)]
#endif
#if NET8_0_OR_GREATER
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
#endif
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlException.xml' path='docs/members[@name="SqlException"]/ToString/*'/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<TargetFrameworks>net7.0;net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition="$(ReferenceType)=='NetStandard' AND $(TargetNetStandardVersion)=='netstandard2.1'">netstandard2.1</TargetFrameworks>
<IntermediateOutputPath>$(ObjFolder)$(Configuration)\$(AssemblyName)\ref\</IntermediateOutputPath>
<OutputPath>$(BinFolder)$(Configuration)\$(AssemblyName)\ref\</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Microsoft.Data.SqlClient</AssemblyName>
<TargetFrameworks>net7.0;net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition="$(ReferenceType)=='NetStandard' AND $(TargetNetStandardVersion)=='netstandard2.1'">netstandard2.1</TargetFrameworks>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(OSGroup)' == 'AnyOS'">Microsoft.Data.SqlClient is not supported on this platform.</GeneratePlatformNotSupportedAssemblyMessage>
<OSGroup Condition="'$(OSGroup)' == ''">$(OS)</OSGroup>
Expand Down Expand Up @@ -666,8 +666,8 @@
<Compile Include="Microsoft\Data\SqlClient\TdsParserStateObject.netcore.cs" />
<Compile Include="Microsoft\Data\SqlClient\TdsParserStateObjectManaged.cs" />
</ItemGroup>
<!--This will exclude SqlTypeWorkarounds.netcore.cs from Net7 and greater versions-->
<ItemGroup Condition="'$(OSGroup)' != 'AnyOS' AND !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
<!--This will exclude SqlTypeWorkarounds.netcore.cs from Net8 and greater versions-->
<ItemGroup Condition="'$(OSGroup)' != 'AnyOS' AND !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<Compile Include="Microsoft\Data\SqlTypes\SqlTypeWorkarounds.netcore.cs" />
</ItemGroup>
<!-- Windows only -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ private OperationAbortedException(string message, Exception innerException) : ba
HResult = unchecked((int)0x80131936);
}

#if NET8_0_OR_GREATER
[Obsolete]
#endif
private OperationAbortedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ private SqlException(string message, SqlErrorCollection errorCollection, Excepti
_errors = errorCollection;
_clientConnectionId = conId;
}

#if NET8_0_OR_GREATER
[System.Obsolete]
#endif
private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc)
{
#if NETFRAMEWORK
Expand All @@ -60,6 +62,9 @@ private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc)
}

/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlException.xml' path='docs/members[@name="SqlException"]/GetObjectData/*' />
#if NET8_0_OR_GREATER
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
#endif
public override void GetObjectData(SerializationInfo si, StreamingContext context)
{
base.GetObjectData(si, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,19 @@ public static void ConnectionCanCreateBatch()
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void SqlBatchCanCreateParameter()
{
using (var connection = new SqlConnection(DataTestUtility.TCPConnectionString))
using (var batch = connection.CreateBatch())
{
SqlBatchCommand batchCommand = new SqlBatchCommand("SELECT @p");

Assert.True(batchCommand.CanCreateParameter);
SqlParameter parameter = batchCommand.CreateParameter();
Assert.NotNull(parameter);
parameter.ParameterName = "@p";
parameter.Value = 1;
batchCommand.Parameters.Add(parameter);

batch.ExecuteNonQuery();

}
using var connection = new SqlConnection(DataTestUtility.TCPConnectionString);
connection.Open();
JRahnama marked this conversation as resolved.
Show resolved Hide resolved
using DbBatch batch = connection.CreateBatch();
SqlBatchCommand batchCommand = new SqlBatchCommand("SELECT @p");

Assert.True(batchCommand.CanCreateParameter);
SqlParameter parameter = (SqlParameter)batchCommand.CreateParameter();
Assert.NotNull(parameter);
parameter.ParameterName = "@p";
parameter.Value = 1;
batchCommand.Parameters.Add(parameter);
batch.BatchCommands.Add(batchCommand);
batch.ExecuteNonQuery();
}
#endif

Expand Down Expand Up @@ -443,7 +441,6 @@ public static void ExecuteNonQuery()
}
}
}

Assert.Equal(3, batch.Commands.Count);
Assert.Equal(2, count);
Assert.Equal(1, batch.Commands[0].RecordsAffected);
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;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Configurations>Debug;Release;</Configurations>
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)</IntermediateOutputPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<StartupObject>Microsoft.Data.SqlClient.ExtUtilities.Runner</StartupObject>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<PackageType>MSBuildSdk</PackageType>
<IncludeBuildOutput>false</IncludeBuildOutput>
Expand Down
Loading
Loading