Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/dotnet/SqlClient into add-c…
Browse files Browse the repository at this point in the history
…omponentmodel-to-netcoresrc

# Conflicts:
#	src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
  • Loading branch information
JRahnama committed Jul 13, 2021
2 parents 42850a9 + 23fcd00 commit 54e58ef
Show file tree
Hide file tree
Showing 84 changed files with 2,442 additions and 1,953 deletions.
13 changes: 13 additions & 0 deletions BUILDGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,16 @@ dotnet test <test_properties...> --collect:"Code Coverage"
```bash
dotnet test <test_properties...> --collect:"XPlat Code Coverage"
```

## Run Performance Tests

### Running Performance test project directly:

Project location from Root: `src\Microsoft.Data.SqlClient\tests\PerformanceTests\Microsoft.Data.SqlClient.PerformanceTests.csproj`
Configure `runnerconfig.json` file with connection string and preferred settings to run Benchmark Jobs.

```
cd src\Microsoft.Data.SqlClient\tests\PerformanceTests
dotnet run -c Release -f netcoreapp3.1|net5.0
```
_Only "**Release** Configuration" applies to Performance Tests_
12 changes: 6 additions & 6 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@
<Target Name="BuildTestsNetFx" DependsOnTargets="RestoreTestsNetFx;BuildAKVNetFx;BuildFunctionalTestsNetFx;BuildManualTestsNetFx;" />

<Target Name="RestoreNetCore">
<MSBuild Projects="@(NetCoreDriver)" Targets="restore" Properties="TestTargetOS=$(TestOS)netcoreapp" />
<MSBuild Projects="@(NetCoreDriver)" Targets="restore" />
</Target>

<Target Name="RestoreTestsNetCore">
<MSBuild Projects="@(ManualTests)" Targets="restore" Properties="TestTargetOS=$(TestOS)netcoreapp" />
<MSBuild Projects="@(FunctionalTests)" Targets="restore" Properties="TestTargetOS=$(TestOS)netcoreapp" />
<MSBuild Projects="@(ManualTests)" Targets="restore" />
<MSBuild Projects="@(FunctionalTests)" Targets="restore" />
</Target>

<Target Name="RestoreNetFx" Condition="'$(IsEnabledWindows)' == 'true'">
<MSBuild Projects="@(NetFxDriver)" Targets="restore" Properties="TestTargetOS=$(TestOS)netfx" />
<MSBuild Projects="@(NetFxDriver)" Targets="restore" />
</Target>

<Target Name="RestoreTestsNetFx">
<MSBuild Projects="@(ManualTests)" Targets="restore" Properties="TestTargetOS=$(TestOS)netfx" />
<MSBuild Projects="@(FunctionalTests)" Targets="restore" Properties="TestTargetOS=$(TestOS)netfx" />
<MSBuild Projects="@(ManualTests)" Targets="restore" />
<MSBuild Projects="@(FunctionalTests)" Targets="restore" />
</Target>

<Target Name="BuildTools" Condition="'$(BuildTools)' == 'true'">
Expand Down
4 changes: 1 addition & 3 deletions doc/samples/AzureKeyVaultProviderExample_2_0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,5 @@ public CustomerRecord(int id, string fName, string lName)
}
}
}

//</Snippet1>

}
//</Snippet1>
795 changes: 70 additions & 725 deletions src/Microsoft.Data.SqlClient.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ProjectGuid>{9073ABEF-92E0-4702-BB23-2C99CEF9BDD7}</ProjectGuid>
<TargetGroup Condition="$(TargetFramework.StartsWith('netcoreapp')) OR $(TargetFramework.StartsWith('netstandard'))">netcoreapp</TargetGroup>
<TargetGroup Condition="$(TargetFramework.StartsWith('net4'))">netfx</TargetGroup>
<Configurations>Debug;Release;net461-Release;net461-Debug;netcoreapp2.1-Debug;netcoreapp2.1-Release;netcoreapp3.1-Debug;netcoreapp3.1-Release</Configurations>
<Configurations>Debug;Release;</Configurations>
<Platforms>AnyCPU;x86;x64</Platforms>
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform)\$(AddOnName)</IntermediateOutputPath>
<OutputPath>$(BinFolder)$(Configuration).$(Platform)\$(AddOnName)</OutputPath>
Expand Down
36 changes: 20 additions & 16 deletions src/Microsoft.Data.SqlClient/add-ons/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,41 @@
<Import Project="..\..\Directory.Build.props" />

<PropertyGroup>
<OSGroup Condition="$(OSGroup) == ''">$(OS)</OSGroup>
<TargetsWindows Condition="'$(OSGroup)'=='Windows_NT'">true</TargetsWindows>
<TargetsUnix Condition="'$(OSGroup)'=='Unix'">true</TargetsUnix>
<ReferenceType Condition="'$(ReferenceType)'==''">Project</ReferenceType>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
</PropertyGroup>


<!--These properties can be modified locally to target .NET version of choice to build and test entire test suite-->
<PropertyGroup>
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
<TargetNetFxVersion Condition="'$(TargetNetFxVersion)' == ''">net461</TargetNetFxVersion>
<TargetNetStandardVersion Condition="'$(TargetNetStandardVersion)' == ''">netstandard2.0</TargetNetStandardVersion>
<TargetNetCoreVersion Condition="'$(ReferenceType)' == 'NetStandard' AND $(TargetNetStandardVersion)=='netstandard2.1'">netcoreapp3.1</TargetNetCoreVersion>
<TargetNetCoreVersion Condition="'$(TargetNetCoreVersion)' == ''">netcoreapp2.1</TargetNetCoreVersion>
</PropertyGroup>

<ItemGroup>
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
</ItemGroup>
<Choose>
<!-- Set Default Target Framework when building for Debug and Release configurations. (Visual Studio) -->
<When Condition="'$(TestTargetOS)' == '' AND ('$(Configuration)' == 'Debug' OR '$(Configuration)' == 'Release')">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
</When>
<!-- Set Target Framework when TestTargetOS is not empty. (Command Line) -->
<When Condition="'$(TestTargetOS)' != ''">
<PropertyGroup>
<TargetFramework Condition="'$(TestTargetOS)' == 'Windowsnetstandard' OR '$(TestTargetOS)' == 'Unixnetstandard'">netstandard2.0</TargetFramework>
<TargetFramework Condition="'$(TestTargetOS)' == 'Windowsnetcoreapp' OR '$(TestTargetOS)' == 'Unixnetcoreapp'">netcoreapp2.1</TargetFramework>
<TargetFramework Condition="('$(TestTargetOS)' == 'Windowsnetcoreapp' OR '$(TestTargetOS)' == 'Unixnetcoreapp') AND ($(ReferenceType)=='NetStandard' AND $(TargetNetStandardVersion)=='netstandard2.1')">netcoreapp3.1</TargetFramework>
<TargetFramework Condition="'$(TestTargetOS)' == 'Windowsnetfx'">net461</TargetFramework>
<When Condition="'$(TestTargetOS)' == ''">
<PropertyGroup>
<TargetFrameworks Condition="'$(TargetsWindows)' == 'true'">$(TargetNetFxVersion);$(TargetNetCoreVersion);$(TargetNetStandardVersion)</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetsUnix)' == 'true'">$(TargetNetCoreVersion);$(TargetNetStandardVersion)</TargetFrameworks>
</PropertyGroup>
</When>
<!-- Set Target Framework when TestTargetOS is empty and Configuration is neither Debug nor Release. (Visual Studio) -->
<!-- Set Target Framework when TestTargetOS is not empty. (Command Line) -->
<Otherwise>
<PropertyGroup>
<TargetFramework>$(Configuration.Split('-')[0])</TargetFramework>
<TargetFrameworks Condition="'$(TestTargetOS)' == 'Windowsnetstandard' OR '$(TestTargetOS)' == 'Unixnetstandard'">netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(TestTargetOS)' == 'Windowsnetcoreapp' OR '$(TestTargetOS)' == 'Unixnetcoreapp'">netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="('$(TestTargetOS)' == 'Windowsnetcoreapp' OR '$(TestTargetOS)' == 'Unixnetcoreapp') AND ($(ReferenceType)=='NetStandard' AND $(TargetNetStandardVersion)=='netstandard2.1')">netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(TestTargetOS)' == 'Windowsnetfx'">net461</TargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<OutputPath>$(BinFolder)$(Configuration)\$(AssemblyName)\ref\</OutputPath>
<DocumentationFile>$(OutputPath)\$(TargetFramework)\Microsoft.Data.SqlClient.xml</DocumentationFile>
<Product>Core $(BaseProduct)</Product>
<Configurations>Debug;Release;netcoreapp2.1-Debug;netcoreapp2.1-Release;netcoreapp3.1-Debug;netcoreapp3.1-Release</Configurations>
<Configurations>Debug;Release;</Configurations>
<TargetGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))">netcoreapp</TargetGroup>
<TargetGroup Condition="$(TargetFramework.StartsWith('netstandard'))">netstandard</TargetGroup>
<Platforms>AnyCPU;x64;x86</Platforms>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Data.SqlClient.SNI
{
/// <summary>
/// This class implements a FIFO Queue with SemaphoreSlim for ordered execution of parallel tasks.
/// Currently used in Managed SNI (SNISslStream) to override SslStream's WriteAsync implementation.
/// </summary>
internal sealed partial class ConcurrentQueueSemaphore
{
private readonly SemaphoreSlim _semaphore;
private readonly ConcurrentQueue<TaskCompletionSource<bool>> _queue;

public ConcurrentQueueSemaphore(int initialCount)
{
_semaphore = new SemaphoreSlim(initialCount);
_queue = new ConcurrentQueue<TaskCompletionSource<bool>>();
}

public Task WaitAsync(CancellationToken cancellationToken)
{
// try sync wait with 0 which will not block to see if we need to do an async wait
if (_semaphore.Wait(0, cancellationToken))
{
return Task.CompletedTask;
}
else
{
var tcs = new TaskCompletionSource<bool>();
_queue.Enqueue(tcs);
_semaphore.WaitAsync().ContinueWith(
continuationAction: static (Task task, object state) =>
{
ConcurrentQueue<TaskCompletionSource<bool>> queue = (ConcurrentQueue<TaskCompletionSource<bool>>)state;
if (queue.TryDequeue(out TaskCompletionSource<bool> popped))
{
popped.SetResult(true);
}
},
state: _queue,
cancellationToken: cancellationToken
);
return tcs.Task;
}
}

public void Release()
{
_semaphore.Release();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal enum SNISMUXFlags
internal class SNICommon
{
private const string s_className = nameof(SNICommon);

// Each error number maps to SNI_ERROR_* in String.resx
internal const int ConnTerminatedError = 2;
internal const int InvalidParameterError = 5;
Expand Down Expand Up @@ -220,11 +220,12 @@ internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uin
/// <param name="provider">SNI provider</param>
/// <param name="sniError">SNI error code</param>
/// <param name="sniException">SNI Exception</param>
/// <param name="nativeErrorCode">Native SNI error code</param>
/// <returns></returns>
internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException)
internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException, uint nativeErrorCode = 0)
{
SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.ERR, "Provider = {0}, SNI Error = {1}, Exception = {2}", args0: provider, args1: sniError, args2: sniException?.Message);
return ReportSNIError(new SNIError(provider, sniError, sniException));
return ReportSNIError(new SNIError(provider, sniError, sniException, nativeErrorCode));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Microsoft.Data.SqlClient.SNI
/// </summary>
internal class SNIError
{
// Error numbers from native SNI implementation
internal const uint CertificateValidationErrorCode = 2148074277;

public readonly SNIProviders provider;
public readonly string errorMessage;
public readonly uint nativeError;
Expand All @@ -21,24 +24,24 @@ internal class SNIError

public SNIError(SNIProviders provider, uint nativeError, uint sniErrorCode, string errorMessage)
{
this.lineNumber = 0;
this.function = string.Empty;
lineNumber = 0;
function = string.Empty;
this.provider = provider;
this.nativeError = nativeError;
this.sniError = sniErrorCode;
sniError = sniErrorCode;
this.errorMessage = errorMessage;
this.exception = null;
exception = null;
}

public SNIError(SNIProviders provider, uint sniErrorCode, Exception sniException)
public SNIError(SNIProviders provider, uint sniErrorCode, Exception sniException, uint nativeErrorCode = 0)
{
this.lineNumber = 0;
this.function = string.Empty;
lineNumber = 0;
function = string.Empty;
this.provider = provider;
this.nativeError = 0;
this.sniError = sniErrorCode;
this.errorMessage = string.Empty;
this.exception = sniException;
nativeError = nativeErrorCode;
sniError = sniErrorCode;
errorMessage = string.Empty;
exception = sniException;
}
}
}
Loading

0 comments on commit 54e58ef

Please sign in to comment.