Skip to content

Commit 155a535

Browse files
authored
Rework TdsParserStateObjectManaged with nullable annotations (#1555)
1 parent 2b364f4 commit 155a535

File tree

6 files changed

+238
-75
lines changed

6 files changed

+238
-75
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@
505505
<Compile Include="..\..\src\Resources\StringsHelper.cs">
506506
<Link>Resources\StringsHelper.cs</Link>
507507
</Compile>
508+
<Compile Include="..\..\src\System\Diagnostics\CodeAnalysis.cs">
509+
<Link>Common\System\Diagnostics\CodeAnalysis.cs</Link>
510+
</Compile>
508511
</ItemGroup>
509512
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard' OR '$(TargetGroup)' == 'netcoreapp' OR '$(IsUAPAssembly)' == 'true'">
510513
<Compile Include="Microsoft.Data.SqlClient.TypeForwards.cs" />

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

Lines changed: 124 additions & 75 deletions
Large diffs are not rendered by default.

src/Microsoft.Data.SqlClient/netcore/src/Resources/Strings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.Data.SqlClient/netcore/src/Resources/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,4 +1935,7 @@
19351935
<data name="AAD_Token_Retrieving_Timeout" xml:space="preserve">
19361936
<value>Connection timed out while retrieving an access token using '{0}' authentication method. Last error: {1}: {2}</value>
19371937
</data>
1938+
<data name="SNI_IncorrectPhysicalConnectionType" xml:space="preserve">
1939+
<value>Incorrect physicalConnection type.</value>
1940+
</data>
19381941
</root>

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,9 @@ internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel
15651565
return InvalidEnumerationValue(typeof(IsolationLevel), (int)value);
15661566
}
15671567

1568+
// ConnectionUtil
1569+
internal static Exception IncorrectPhysicalConnectionType() => new ArgumentException(StringsHelper.GetString(StringsHelper.SNI_IncorrectPhysicalConnectionType));
1570+
15681571
// IDataParameter.Direction
15691572
internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
15701573
{
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
namespace System.Diagnostics.CodeAnalysis
6+
{
7+
#if NETSTANDARD2_0
8+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property)]
9+
internal sealed class AllowNullAttribute : Attribute
10+
{
11+
}
12+
13+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property)]
14+
internal sealed class DisallowNullAttribute : Attribute
15+
{
16+
}
17+
18+
[AttributeUsage(AttributeTargets.Method)]
19+
internal sealed class DoesNotReturnAttribute : Attribute
20+
{
21+
}
22+
23+
[AttributeUsage(AttributeTargets.Parameter)]
24+
internal sealed class DoesNotReturnIfAttribute : Attribute
25+
{
26+
public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue;
27+
public bool ParameterValue { get; }
28+
}
29+
30+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
31+
internal sealed class MaybeNullAttribute : Attribute
32+
{
33+
}
34+
35+
[AttributeUsage(AttributeTargets.Parameter)]
36+
internal sealed class MaybeNullWhenAttribute : Attribute
37+
{
38+
public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
39+
public bool ReturnValue { get; }
40+
}
41+
42+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
43+
internal sealed class NotNullAttribute : Attribute
44+
{
45+
}
46+
47+
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true)]
48+
internal sealed class NotNullIfNotNullAttribute : Attribute
49+
{
50+
public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName;
51+
public string ParameterName { get; }
52+
}
53+
54+
[AttributeUsage(AttributeTargets.Parameter)]
55+
internal sealed class NotNullWhenAttribute : Attribute
56+
{
57+
public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
58+
public bool ReturnValue { get; }
59+
}
60+
#endif
61+
62+
#if !NET5_0_OR_GREATER
63+
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
64+
internal sealed class MemberNotNullAttribute : Attribute
65+
{
66+
public MemberNotNullAttribute(string member) => Members = new string[]
67+
{
68+
member
69+
};
70+
71+
public MemberNotNullAttribute(params string[] members) => Members = members;
72+
73+
public string[] Members { get; }
74+
}
75+
76+
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
77+
internal sealed class MemberNotNullWhenAttribute : Attribute
78+
{
79+
public MemberNotNullWhenAttribute(bool returnValue, string member)
80+
{
81+
ReturnValue = returnValue;
82+
Members = new string[1] { member };
83+
}
84+
85+
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
86+
{
87+
ReturnValue = returnValue;
88+
Members = members;
89+
}
90+
91+
public bool ReturnValue { get; }
92+
93+
public string[] Members { get; }
94+
}
95+
#endif
96+
}

0 commit comments

Comments
 (0)