Skip to content

Commit ab9fbb7

Browse files
authored
Add shared SqlFacetAttribute (#757)
1 parent 741a5dd commit ab9fbb7

File tree

8 files changed

+122
-20
lines changed

8 files changed

+122
-20
lines changed

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,6 @@
55
// Changes to this file must follow the http://aka.ms/api-review process.
66
// ------------------------------------------------------------------------------
77

8-
namespace Microsoft.Data.SqlClient.Server
9-
{
10-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/SqlFacetAttribute/*'/>
11-
[System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue | System.AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
12-
public partial class SqlFacetAttribute : System.Attribute
13-
{
14-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/ctor/*'/>
15-
public SqlFacetAttribute() { }
16-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsFixedLength/*'/>
17-
public bool IsFixedLength { get { throw null; } set { } }
18-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsNullable/*'/>
19-
public bool IsNullable { get { throw null; } set { } }
20-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/MaxSize/*'/>
21-
public int MaxSize { get { throw null; } set { } }
22-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Precision/*'/>
23-
public int Precision { get { throw null; } set { } }
24-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Scale/*'/>
25-
public int Scale { get { throw null; } set { } }
26-
}
27-
}
288
namespace Microsoft.Data.SqlClient
299
{
3010
public partial class SqlDataReader : System.Data.Common.IDbColumnSchemaGenerator

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,23 @@ public virtual void SetValue(int ordinal, object value) { }
18101810
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/SetValues/*'/>
18111811
public virtual int SetValues(params object[] values) { throw null; }
18121812
}
1813+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/SqlFacetAttribute/*'/>
1814+
[System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue | System.AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
1815+
public partial class SqlFacetAttribute : System.Attribute
1816+
{
1817+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/ctor/*'/>
1818+
public SqlFacetAttribute() { }
1819+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsFixedLength/*'/>
1820+
public bool IsFixedLength { get { throw null; } set { } }
1821+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsNullable/*'/>
1822+
public bool IsNullable { get { throw null; } set { } }
1823+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/MaxSize/*'/>
1824+
public int MaxSize { get { throw null; } set { } }
1825+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Precision/*'/>
1826+
public int Precision { get { throw null; } set { } }
1827+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Scale/*'/>
1828+
public int Scale { get { throw null; } set { } }
1829+
}
18131830
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFunctionAttribute.xml' path='docs/members[@name="SqlFunctionAttribute"]/SqlFunctionAttribute/*' />
18141831
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple = false, Inherited = false), System.SerializableAttribute]
18151832
public partial class SqlFunctionAttribute : System.Attribute

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiXetterTypeCode.cs">
112112
<Link>Microsoft\Data\SqlClient\Server\SmiXetterTypeCode.cs</Link>
113113
</Compile>
114+
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlFacetAttribute.cs">
115+
<Link>Microsoft\Data\SqlClient\Server\SqlFacetAttribute.cs</Link>
116+
</Compile>
114117
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlFunctionAttribute.cs">
115118
<Link>Microsoft\Data\SqlClient\Server\SqlFunctionAttribute.cs</Link>
116119
</Compile>

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,23 @@ public virtual void SetValue(int ordinal, object value) { }
19591959
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/SetValues/*'/>
19601960
public virtual int SetValues(params object[] values) { throw null; }
19611961
}
1962+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/SqlFacetAttribute/*'/>
1963+
[System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue | System.AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
1964+
public partial class SqlFacetAttribute : System.Attribute
1965+
{
1966+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/ctor/*'/>
1967+
public SqlFacetAttribute() { }
1968+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsFixedLength/*'/>
1969+
public bool IsFixedLength { get { throw null; } set { } }
1970+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsNullable/*'/>
1971+
public bool IsNullable { get { throw null; } set { } }
1972+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/MaxSize/*'/>
1973+
public int MaxSize { get { throw null; } set { } }
1974+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Precision/*'/>
1975+
public int Precision { get { throw null; } set { } }
1976+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Scale/*'/>
1977+
public int Scale { get { throw null; } set { } }
1978+
}
19621979
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFunctionAttribute.xml' path='docs/members[@name="SqlFunctionAttribute"]/SqlFunctionAttribute/*' />
19631980
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple = false, Inherited = false), System.SerializableAttribute]
19641981
public partial class SqlFunctionAttribute : System.Attribute

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@
163163
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiXetterTypeCode.cs">
164164
<Link>Microsoft\Data\SqlClient\Server\SmiXetterTypeCode.cs</Link>
165165
</Compile>
166+
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlFacetAttribute.cs">
167+
<Link>Microsoft\Data\SqlClient\Server\SqlFacetAttribute.cs</Link>
168+
</Compile>
166169
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SqlFunctionAttribute.cs">
167170
<Link>Microsoft\Data\SqlClient\Server\SqlFunctionAttribute.cs</Link>
168171
</Compile>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Microsoft.Data.SqlClient.Server
8+
{
9+
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/SqlFacetAttribute/*' />
10+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.ReturnValue | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
11+
public class SqlFacetAttribute : Attribute
12+
{
13+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/ctor/*'/>
14+
public SqlFacetAttribute() { }
15+
16+
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsFixedLength/*' />
17+
public bool IsFixedLength
18+
{
19+
get;
20+
set;
21+
}
22+
23+
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/MaxSize/*' />
24+
public int MaxSize
25+
{
26+
get;
27+
set;
28+
}
29+
30+
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Precision/*' />
31+
public int Precision
32+
{
33+
get;
34+
set;
35+
}
36+
37+
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/Scale/*' />
38+
public int Scale
39+
{
40+
get;
41+
set;
42+
}
43+
44+
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlFacetAttribute.xml' path='docs/members[@name="SqlFacetAttribute"]/IsNullable/*' />
45+
public bool IsNullable
46+
{
47+
get;
48+
set;
49+
}
50+
}
51+
}

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
@@ -42,6 +42,7 @@
4242
<Compile Include="SqlCredentialTest.cs" />
4343
<Compile Include="SqlDataRecordTest.cs" />
4444
<Compile Include="SqlExceptionTest.cs" />
45+
<Compile Include="SqlFacetAttributeTest.cs" />
4546
<Compile Include="SqlParameterTest.cs" />
4647
<Compile Include="SqlClientFactoryTest.cs" />
4748
<Compile Include="SqlErrorCollectionTest.cs" />
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Microsoft.Data.SqlClient.Server;
6+
using Xunit;
7+
8+
namespace System.Data.SqlClient.Tests
9+
{
10+
public class SqlFacetAttributeTests
11+
{
12+
[Fact]
13+
public void Basic()
14+
{
15+
var attrib = new SqlFacetAttribute();
16+
17+
attrib.IsFixedLength = true;
18+
attrib.IsNullable = false;
19+
attrib.MaxSize = 123;
20+
attrib.Precision = 234;
21+
attrib.Scale = 345;
22+
23+
Assert.True(attrib.IsFixedLength);
24+
Assert.False(attrib.IsNullable);
25+
Assert.Equal(123, attrib.MaxSize);
26+
Assert.Equal(234, attrib.Precision);
27+
Assert.Equal(345, attrib.Scale);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)