Skip to content

Commit d3342fa

Browse files
Feature | Enable FILESTREAM for .NET Standard on Windows
Also enable tests
1 parent fbfd5d7 commit d3342fa

File tree

13 files changed

+254
-161
lines changed

13 files changed

+254
-161
lines changed

BUILDGUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Manual Tests require the below setup to run:
119119
|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}_ |
120120
|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.|
121121
|SupportsIntegratedSecurity | (Optional) Whether or not the USER running tests has integrated security access to the target SQL Server.| `true` OR `false`|
122-
|SupportsFileStream | (Optional) Whether or not FileStream is enabled on SQL Server| `true` OR `false`|
122+
|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\\` |
123123
|UseManagedSNIOnWindows | (Optional) Enables testing with Managed SNI on Windows| `true` OR `false`|
124124
|IsAzureSynpase | (Optional) When set to 'true', test suite runs compatible tests for Azure Synapse/Parallel Data Warehouse. | `true` OR `false`|
125125

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,59 @@ public SqlNotificationRequest(string userData, string options, int timeout) { }
2828
public string UserData { get { throw null; } set { } }
2929
}
3030
}
31+
namespace Microsoft.Data.SqlTypes
32+
{
33+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/SqlFileStream/*' />
34+
public sealed partial class SqlFileStream : System.IO.Stream
35+
{
36+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ctor1/*' />
37+
public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access) { }
38+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ctor2/*' />
39+
public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access, System.IO.FileOptions options, System.Int64 allocationSize) { }
40+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Name/*' />
41+
public string Name { get { throw null; } }
42+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/TransactionContext/*' />
43+
public byte[] TransactionContext { get { throw null; } }
44+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanRead/*' />
45+
public override bool CanRead { get { throw null; } }
46+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanSeek/*' />
47+
public override bool CanSeek { get { throw null; } }
48+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanTimeout/*' />
49+
public override bool CanTimeout { get { throw null; } }
50+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/CanWrite/*' />
51+
public override bool CanWrite { get { throw null; } }
52+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Length/*' />
53+
public override long Length { get { throw null; } }
54+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Position/*' />
55+
public override long Position { get { throw null; } set { throw null; } }
56+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ReadTimeout/*' />
57+
public override int ReadTimeout { get { throw null; } }
58+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/WriteTimeout/*' />
59+
public override int WriteTimeout { get { throw null; } }
60+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Flush/*' />
61+
public override void Flush() { }
62+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/BeginRead/*' />
63+
public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int count, System.AsyncCallback callback, object state) { throw null; }
64+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/EndRead/*' />
65+
public override int EndRead(System.IAsyncResult asyncResult) { throw null; }
66+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/BeginWrite/*' />
67+
public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int count, System.AsyncCallback callback, System.Object state) { throw null; }
68+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/EndWrite/*' />
69+
public override void EndWrite(System.IAsyncResult asyncResult) { }
70+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Seek/*' />
71+
public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
72+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/SetLength/*' />
73+
public override void SetLength(long value) { throw null; }
74+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Read/*' />
75+
public override int Read(byte[] buffer, int offset, int count) { throw null; }
76+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/ReadByte/*' />
77+
public override int ReadByte() { throw null; }
78+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/Write/*' />
79+
public override void Write(byte[] buffer, int offset, int count) { throw null; }
80+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlFileStream.xml' path='docs/members[@name="SqlFileStream"]/WriteByte/*' />
81+
public override void WriteByte(byte value) { }
82+
}
83+
}
3184
namespace Microsoft.Data.SqlClient
3285
{
3386
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/ActiveDirectoryAuthenticationProvider.xml' path='docs/members[@name="ActiveDirectoryAuthenticationProvider"]/ActiveDirectoryAuthenticationProvider/*'/>

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<Compile Include="Microsoft.Data.SqlClient.Manual.cs" />
2424
</ItemGroup>
2525
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
26-
<Compile Include="Microsoft.Data.SqlClient.NetCoreApp.cs" />
2726
<PackageReference Include="System.Security.Cryptography.Cng" Version="$(SystemSecurityCryptographyCngVersion)" />
2827
</ItemGroup>
2928
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,12 @@
575575
<Compile Include="Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Unix.cs" />
576576
<Compile Include="Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.Unix.cs" />
577577
</ItemGroup>
578-
<!-- SqlFileStream Unix Netcoreapp only -->
579-
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' AND '$(TargetsUnix)' == 'true'">
578+
<!-- SqlFileStream Unix only -->
579+
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
580580
<Compile Include="Microsoft\Data\SqlClient\SqlFileStream.Unsupported.cs" />
581581
</ItemGroup>
582-
<!-- SqlFileStream Windows Netcoreapp only -->
583-
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' AND '$(TargetsWindows)' == 'true'">
582+
<!-- SqlFileStream Windows only -->
583+
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
584584
<Compile Include="$(CommonPath)\CoreLib\Interop\Windows\kernel32\Interop.FileTypes.cs">
585585
<Link>Common\CoreLib\Interop\Windows\kernel32\Interop.FileTypes.cs</Link>
586586
</Compile>

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,12 @@ static private string InitializeNtPath(string path)
689689
// Ensure we have validated and normalized the path before
690690
AssertPathFormat(path);
691691
string uniqueId = Guid.NewGuid().ToString("N");
692-
return System.IO.PathInternal.IsDeviceUNC(path) ? string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", path.Replace(@"\\.", @"\??"), uniqueId)
692+
#if NETSTANDARD
693+
return System.IO.PathInternal.IsDeviceUNC(path.AsSpan())
694+
#else
695+
return System.IO.PathInternal.IsDeviceUNC(path)
696+
#endif
697+
? string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", path.Replace(@"\\.", @"\??"), uniqueId)
693698
: string.Format(CultureInfo.InvariantCulture, @"\??\UNC\{0}\{1}", path.Trim('\\'), uniqueId);
694699
}
695700
}

src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<DefineConstants Condition="'$(TargetGroup)'=='netfx'">$(DefineConstants);NETFX</DefineConstants>
99
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);NETCOREAPP</DefineConstants>
1010
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp' AND !$(TargetFramework.StartsWith('netcoreapp'))">$(DefineConstants);NET50_OR_LATER</DefineConstants>
11+
<DefineConstants Condition="$(ReferenceType.Contains('NetStandard'))">NETSTANDARDREFERNCE</DefineConstants>
1112
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)</IntermediateOutputPath>
1213
<OutputPath>$(BinFolder)$(Configuration).$(Platform).$(AssemblyName)</OutputPath>
1314
</PropertyGroup>

src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void Constructor4()
184184
Assert.Null(cmd.Container);
185185
Assert.True(cmd.DesignTimeVisible);
186186
Assert.Null(cmd.Notification);
187-
#if NETFX
187+
#if NETFX && !NETSTANDARDREFERNCE
188188
// see https://github.com/dotnet/SqlClient/issues/17
189189
Assert.True(cmd.NotificationAutoEnlist);
190190
#endif
@@ -202,7 +202,7 @@ public void Constructor4()
202202
Assert.Null(cmd.Container);
203203
Assert.True(cmd.DesignTimeVisible);
204204
Assert.Null(cmd.Notification);
205-
#if NETFX
205+
#if NETFX && !NETSTANDARDREFERNCE
206206
// see https://github.com/dotnet/SqlClient/issues/17
207207
Assert.True(cmd.NotificationAutoEnlist);
208208
#endif
@@ -224,7 +224,7 @@ public void Clone()
224224
cmd.CommandType = CommandType.StoredProcedure;
225225
cmd.DesignTimeVisible = false;
226226
cmd.Notification = notificationReq;
227-
#if NETFX
227+
#if NETFX && !NETSTANDARDREFERNCE
228228
// see https://github.com/dotnet/SqlClient/issues/17
229229
Assert.True(cmd.NotificationAutoEnlist);
230230
#endif
@@ -240,7 +240,7 @@ public void Clone()
240240
Assert.Null(cmd.Connection);
241241
Assert.False(cmd.DesignTimeVisible);
242242
Assert.Same(notificationReq, cmd.Notification);
243-
#if NETFX
243+
#if NETFX && !!NETSTANDARDREFERNCE
244244
// see https://github.com/dotnet/SqlClient/issues/17
245245
Assert.True(cmd.NotificationAutoEnlist);
246246
#endif

0 commit comments

Comments
 (0)