Skip to content

Commit

Permalink
Feature | Enable FILESTREAM for .NET Standard on Windows
Browse files Browse the repository at this point in the history
Also enable tests
  • Loading branch information
cheenamalhotra committed Aug 31, 2021
1 parent fbfd5d7 commit 96808b5
Show file tree
Hide file tree
Showing 13 changed files with 254 additions and 161 deletions.
2 changes: 1 addition & 1 deletion BUILDGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Manual Tests require the below setup to run:
|AzureKeyVaultClientSecret | (Optional) "Client Secret" of the Active Directory registered application, granted access to the Azure Key Vault specified in `AZURE_KEY_VAULT_URL` | _{Client Application Secret}_ |
|LocalDbAppName | (Optional) If Local Db Testing is supported, this property configures the name of Local DB App instance available in client environment. Empty string value disables Local Db testing. | Name of Local Db App to connect to.|
|SupportsIntegratedSecurity | (Optional) Whether or not the USER running tests has integrated security access to the target SQL Server.| `true` OR `false`|
|SupportsFileStream | (Optional) Whether or not FileStream is enabled on SQL Server| `true` OR `false`|
|FileStreamDirectory | (Optional) If File Stream is enabled on SQL Server, pass local directory path to be used for setting up File Stream enabled database. | `D:\\escaped\\absolute\\path\\to\\directory\\` |
|UseManagedSNIOnWindows | (Optional) Enables testing with Managed SNI on Windows| `true` OR `false`|
|IsAzureSynpase | (Optional) When set to 'true', test suite runs compatible tests for Azure Synapse/Parallel Data Warehouse. | `true` OR `false`|

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,59 @@ public SqlNotificationRequest(string userData, string options, int timeout) { }
public string UserData { get { throw null; } set { } }
}
}
namespace Microsoft.Data.SqlTypes
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/SqlFileStream/*' />
public sealed partial class SqlFileStream : System.IO.Stream
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ctor1/*' />
public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ctor2/*' />
public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access, System.IO.FileOptions options, System.Int64 allocationSize) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Name/*' />
public string Name { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/TransactionContext/*' />
public byte[] TransactionContext { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanRead/*' />
public override bool CanRead { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanSeek/*' />
public override bool CanSeek { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanTimeout/*' />
public override bool CanTimeout { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanWrite/*' />
public override bool CanWrite { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Length/*' />
public override long Length { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Position/*' />
public override long Position { get { throw null; } set { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ReadTimeout/*' />
public override int ReadTimeout { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/WriteTimeout/*' />
public override int WriteTimeout { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Flush/*' />
public override void Flush() { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/BeginRead/*' />
public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int count, System.AsyncCallback callback, object state) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/EndRead/*' />
public override int EndRead(System.IAsyncResult asyncResult) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/BeginWrite/*' />
public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int count, System.AsyncCallback callback, System.Object state) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/EndWrite/*' />
public override void EndWrite(System.IAsyncResult asyncResult) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Seek/*' />
public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/SetLength/*' />
public override void SetLength(long value) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Read/*' />
public override int Read(byte[] buffer, int offset, int count) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ReadByte/*' />
public override int ReadByte() { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Write/*' />
public override void Write(byte[] buffer, int offset, int count) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/WriteByte/*' />
public override void WriteByte(byte value) { }
}
}
namespace Microsoft.Data.SqlClient
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/ActiveDirectoryAuthenticationProvider.xml' path='docs/members[@name="ActiveDirectoryAuthenticationProvider"]/ActiveDirectoryAuthenticationProvider/*'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<Compile Include="Microsoft.Data.SqlClient.Manual.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="Microsoft.Data.SqlClient.NetCoreApp.cs" />
<PackageReference Include="System.Security.Cryptography.Cng" Version="$(SystemSecurityCryptographyCngVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,12 @@
<Compile Include="Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Unix.cs" />
<Compile Include="Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.Unix.cs" />
</ItemGroup>
<!-- SqlFileStream Unix Netcoreapp only -->
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' AND '$(TargetsUnix)' == 'true'">
<!-- SqlFileStream Unix only -->
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="Microsoft\Data\SqlClient\SqlFileStream.Unsupported.cs" />
</ItemGroup>
<!-- SqlFileStream Windows Netcoreapp only -->
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' AND '$(TargetsWindows)' == 'true'">
<!-- SqlFileStream Windows only -->
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="$(CommonPath)\CoreLib\Interop\Windows\kernel32\Interop.FileTypes.cs">
<Link>Common\CoreLib\Interop\Windows\kernel32\Interop.FileTypes.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,12 @@ static private string InitializeNtPath(string path)
// Ensure we have validated and normalized the path before
AssertPathFormat(path);
string uniqueId = Guid.NewGuid().ToString("N");
return System.IO.PathInternal.IsDeviceUNC(path) ? string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", path.Replace(@"\\.", @"\??"), uniqueId)
#if NETSTANDARD
return System.IO.PathInternal.IsDeviceUNC(path.AsSpan())
#else
return System.IO.PathInternal.IsDeviceUNC(path)
#endif
? string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", path.Replace(@"\\.", @"\??"), uniqueId)
: string.Format(CultureInfo.InvariantCulture, @"\??\UNC\{0}\{1}", path.Trim('\\'), uniqueId);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<DefineConstants Condition="'$(TargetGroup)'=='netfx'">$(DefineConstants);NETFX</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>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void Constructor4()
Assert.Null(cmd.Container);
Assert.True(cmd.DesignTimeVisible);
Assert.Null(cmd.Notification);
#if NETFX
#if NETFX && !NETSTANDARDREFERNCE
// see https://github.com/dotnet/SqlClient/issues/17
Assert.True(cmd.NotificationAutoEnlist);
#endif
Expand All @@ -202,7 +202,7 @@ public void Constructor4()
Assert.Null(cmd.Container);
Assert.True(cmd.DesignTimeVisible);
Assert.Null(cmd.Notification);
#if NETFX
#if NETFX && !NETSTANDARDREFERNCE
// see https://github.com/dotnet/SqlClient/issues/17
Assert.True(cmd.NotificationAutoEnlist);
#endif
Expand All @@ -224,7 +224,7 @@ public void Clone()
cmd.CommandType = CommandType.StoredProcedure;
cmd.DesignTimeVisible = false;
cmd.Notification = notificationReq;
#if NETFX
#if NETFX && !NETSTANDARDREFERNCE
// see https://github.com/dotnet/SqlClient/issues/17
Assert.True(cmd.NotificationAutoEnlist);
#endif
Expand All @@ -240,7 +240,7 @@ public void Clone()
Assert.Null(cmd.Connection);
Assert.False(cmd.DesignTimeVisible);
Assert.Same(notificationReq, cmd.Notification);
#if NETFX
#if NETFX && !!NETSTANDARDREFERNCE
// see https://github.com/dotnet/SqlClient/issues/17
Assert.True(cmd.NotificationAutoEnlist);
#endif
Expand Down
Loading

0 comments on commit 96808b5

Please sign in to comment.