-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add SqlFacetAttribute #32245
Add SqlFacetAttribute #32245
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// 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; | ||
|
||
namespace Microsoft.SqlServer.Server | ||
{ | ||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.ReturnValue | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] | ||
public class SqlFacetAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Is this a fixed size field? | ||
/// </summary> | ||
public bool IsFixedLength | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
/// <summary> | ||
/// The maximum size of the field (in bytes or characters depending on the field type) | ||
/// or -1 if the size can be unlimited. | ||
/// </summary> | ||
public int MaxSize | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
/// <summary> | ||
/// Precision, only valid for numeric types. | ||
/// </summary> | ||
public int Precision | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
/// <summary> | ||
/// Scale, only valid for numeric types. | ||
/// </summary> | ||
public int Scale | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
/// <summary> | ||
/// Is this field nullable? | ||
/// </summary> | ||
public bool IsNullable | ||
{ | ||
get; | ||
set; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
<BuildConfigurations> | ||
netstandard-Unix; | ||
netstandard-Windows_NT; | ||
netcoreapp-Unix; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made the netcoreapp configurations OS specific because otherwise if you just do "msbuild" it will pick the netstandard configurations, which is probably not what you want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a quick look at the project file I'm not sure why the netstandard configuration is OS specific but I wouldn't expect the neither of them to need to be OS specific. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. @afsanehr if you don't know of a reason why these tests could be OS specific, I will remove the OS suffixes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the reason why they are OS specific is because the AnyOS implementation assembly throws platform not supported exception. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah OK |
||
netcoreapp-Windows_NT; | ||
</BuildConfigurations> | ||
</PropertyGroup> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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 Microsoft.SqlServer.Server; | ||
using Xunit; | ||
|
||
namespace System.Data.SqlClient.Tests | ||
{ | ||
public class SqlFacetAttributeTests | ||
{ | ||
[Fact] | ||
public void Basic() | ||
{ | ||
var attrib = new SqlFacetAttribute(); | ||
|
||
attrib.IsFixedLength = true; | ||
attrib.IsNullable = false; | ||
attrib.MaxSize = 123; | ||
attrib.Precision = 234; | ||
attrib.Scale = 345; | ||
|
||
Assert.Equal(true, attrib.IsFixedLength); | ||
Assert.Equal(false, attrib.IsNullable); | ||
Assert.Equal(123, attrib.MaxSize); | ||
Assert.Equal(234, attrib.Precision); | ||
Assert.Equal(345, attrib.Scale); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this file is located under System/Data/Sql directory in .NetFramework. Should we move this to the same location?
https://referencesource.microsoft.com/#System.Data/System/Data/Sql/SqlFacetAttribute.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In CoreFX we try to make the folder hierarchy follow the namespace, as I did here. For example we have
src\System.Data.SqlClient\src\Microsoft\SqlServer\Server\SmiMetaData.cs
for a typeMicrosoft.SqlServer.Server.SmiMetadata