Skip to content

Commit

Permalink
FIX | Add Component Model annotations to SqlConnectionStringBuilder c…
Browse files Browse the repository at this point in the history
…lass in netcore's src folder (#1152)
  • Loading branch information
JRahnama committed Aug 20, 2021
1 parent 8412c78 commit d1ff708
Show file tree
Hide file tree
Showing 10 changed files with 1,823 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@
<Compile Include="..\..\src\Resources\ResCategoryAttribute.cs">
<Link>Resources\ResCategoryAttribute.cs</Link>
</Compile>
<Compile Include="..\..\src\Resources\ResDescriptionAttribute.cs">
<Link>Resources\ResDescriptionAttribute.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard' OR '$(TargetGroup)' == 'netcoreapp' OR '$(IsUAPAssembly)' == 'true'">
<Compile Include="Microsoft.Data.SqlClient.TypeForwards.cs" />
Expand Down Expand Up @@ -829,7 +832,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Microsoft\Data\SqlClient\AAsyncCallContext.cs" />

<Compile Include="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlTypes;
Expand All @@ -24,6 +25,10 @@
namespace Microsoft.Data.SqlClient
{
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/SqlCommand/*'/>
[DefaultEvent("RecordsAffected")]
[ToolboxItem(true)]
[DesignerCategory("")]
// TODO: Add designer attribute when Microsoft.VSDesigner.Data.VS.SqlCommandDesigner uses Microsoft.Data.SqlClient
public sealed partial class SqlCommand : DbCommand, ICloneable
{
private static int _objectTypeCount; // EventSource Counter
Expand Down Expand Up @@ -423,6 +428,11 @@ private SqlCommand(SqlCommand from) : this()
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/Connection/*'/>
/// [
[DefaultValue(null)]
[Editor("Microsoft.VSDesigner.Data.Design.DbConnectionEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_Connection)]
new public SqlConnection Connection
{
get
Expand Down Expand Up @@ -499,6 +509,8 @@ private SqlInternalConnectionTds InternalTdsConnection
private static bool IsRetryEnabled => LocalAppContextSwitches.IsRetryEnabled;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/RetryLogicProvider/*' />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public SqlRetryLogicBaseProvider RetryLogicProvider
{
get
Expand All @@ -516,6 +528,10 @@ public SqlRetryLogicBaseProvider RetryLogicProvider
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/Notification/*'/>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // MDAC 90471
[ResCategory(StringsHelper.ResourceNames.DataCategory_Notification)]
[ResDescription(StringsHelper.ResourceNames.SqlCommand_Notification)]
public SqlNotificationRequest Notification
{
get
Expand Down Expand Up @@ -547,6 +563,9 @@ internal SqlStatistics Statistics
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/Transaction/*'/>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_Transaction)]
new public SqlTransaction Transaction
{
get
Expand Down Expand Up @@ -588,6 +607,11 @@ protected override DbTransaction DbTransaction
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/CommandText/*'/>
[DefaultValue("")]
[Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlCommandTextEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing)]
[RefreshProperties(RefreshProperties.All)] // MDAC 67707
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_CommandText)]
public override string CommandText
{
get
Expand All @@ -607,9 +631,15 @@ public override string CommandText
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/ColumnEncryptionSetting/*'/>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.TCE_SqlCommand_ColumnEncryptionSetting)]
public SqlCommandColumnEncryptionSetting ColumnEncryptionSetting => _columnEncryptionSetting;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/CommandTimeout/*'/>
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_CommandTimeout)]
public override int CommandTimeout
{
get
Expand Down Expand Up @@ -650,6 +680,10 @@ private int DefaultCommandTimeout
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/CommandType/*'/>
[DefaultValue(System.Data.CommandType.Text)]
[RefreshProperties(RefreshProperties.All)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_CommandType)]
public override CommandType CommandType
{
get
Expand Down Expand Up @@ -683,6 +717,10 @@ public override CommandType CommandType
// when the DataAdapter design wizard generates the insert/update/delete commands it will
// set the DesignTimeVisible property to false so that cmds won't appear as individual objects
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/DesignTimeVisible/*'/>
[DefaultValue(true)]
[DesignOnly(true)]
[Browsable(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
public override bool DesignTimeVisible
{
get
Expand All @@ -699,6 +737,9 @@ public override bool DesignTimeVisible
public bool EnableOptimizedParameterBinding { get; set; }

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/Parameters/*'/>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_Parameters)]
new public SqlParameterCollection Parameters
{
get
Expand All @@ -723,6 +764,9 @@ protected override DbParameterCollection DbParameterCollection
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/UpdatedRowSource/*'/>
[DefaultValue(System.Data.UpdateRowSource.Both)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_UpdatedRowSource)]
public override UpdateRowSource UpdatedRowSource
{
get
Expand All @@ -747,6 +791,8 @@ public override UpdateRowSource UpdatedRowSource
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/StatementCompleted/*'/>
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_StatementCompleted)]
[ResDescription(StringsHelper.ResourceNames.DbCommand_StatementCompleted)]
public event StatementCompletedEventHandler StatementCompleted
{
add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
Expand All @@ -25,6 +26,8 @@
namespace Microsoft.Data.SqlClient
{
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/SqlConnection/*' />
[DefaultEvent("InfoMessage")]
[DesignerCategory("")]
public sealed partial class SqlConnection : DbConnection, ICloneable
{
private enum CultureCheckState : uint
Expand Down Expand Up @@ -114,6 +117,8 @@ private static readonly ConcurrentDictionary<string, IList<string>> _ColumnEncry
private static bool IsRetryEnabled => LocalAppContextSwitches.IsRetryEnabled;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/RetryLogicProvider/*' />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public SqlRetryLogicBaseProvider RetryLogicProvider
{
get
Expand All @@ -131,12 +136,21 @@ public SqlRetryLogicBaseProvider RetryLogicProvider
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ColumnEncryptionKeyCacheTtl/*' />
[DefaultValue(null)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.TCE_SqlConnection_ColumnEncryptionKeyCacheTtl)]
public static TimeSpan ColumnEncryptionKeyCacheTtl { get; set; } = TimeSpan.FromHours(2);

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ColumnEncryptionQueryMetadataCacheEnabled/*' />
[DefaultValue(null)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.TCE_SqlConnection_ColumnEncryptionQueryMetadataCacheEnabled)]
public static bool ColumnEncryptionQueryMetadataCacheEnabled { get; set; } = true;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ColumnEncryptionTrustedMasterKeyPaths/*' />
[DefaultValue(null)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.TCE_SqlConnection_TrustedColumnMasterKeyPaths)]
public static IDictionary<string, IList<string>> ColumnEncryptionTrustedMasterKeyPaths => _ColumnEncryptionTrustedMasterKeyPaths;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ctorConnectionString/*' />
Expand Down Expand Up @@ -421,6 +435,9 @@ private void CacheConnectionStringProperties()
// Create a new SqlStatistics object if not already there.
// connect the parser to the object.
// if there is no parser at this time we need to connect it after creation.
[DefaultValue(false)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_StatisticsEnabled)]
public bool StatisticsEnabled
{
get
Expand Down Expand Up @@ -546,6 +563,11 @@ internal int ConnectRetryInterval
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ConnectionString/*' />
[DefaultValue("")]
[SettingsBindableAttribute(true)]
[RefreshProperties(RefreshProperties.All)]
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_ConnectionString)]
public override string ConnectionString
{
get
Expand Down Expand Up @@ -602,6 +624,8 @@ public override string ConnectionString
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ConnectionTimeout/*' />
[ResDescription(StringsHelper.ResourceNames.SqlConnection_ConnectionTimeout)]
[ResCategory(StringsHelper.ResourceNames.SqlConnection_DataSource)]
public override int ConnectionTimeout
{
get
Expand All @@ -612,6 +636,8 @@ public override int ConnectionTimeout
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/CommandTimeout/*' />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_ConnectionTimeout)]
public int CommandTimeout
{
get
Expand All @@ -623,6 +649,9 @@ public int CommandTimeout

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/AccessToken/*' />
// AccessToken: To be used for token based authentication
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_AccessToken)]
public string AccessToken
{
get
Expand Down Expand Up @@ -654,6 +683,8 @@ public string AccessToken
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/Database/*' />
[ResDescription(StringsHelper.ResourceNames.SqlConnection_Database)]
[ResCategory(StringsHelper.ResourceNames.SqlConnection_DataSource)]
public override string Database
{
// if the connection is open, we need to ask the inner connection what it's
Expand Down Expand Up @@ -724,6 +755,10 @@ internal string SQLDNSCachingSupportedStateBeforeRedirect
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/DataSource/*' />
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_DataSource)]
[ResCategory(StringsHelper.ResourceNames.SqlConnection_DataSource)]
public override string DataSource
{
get
Expand All @@ -745,6 +780,9 @@ public override string DataSource
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/PacketSize/*' />
[ResCategory(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_PacketSize)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int PacketSize
{
// if the connection is open, we need to ask the inner connection what it's
Expand All @@ -769,6 +807,9 @@ public int PacketSize
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ClientConnectionId/*' />
[ResCategory(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_ClientConnectionId)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Guid ClientConnectionId
{
get
Expand All @@ -794,12 +835,18 @@ public Guid ClientConnectionId
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ServerVersion/*' />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_ServerVersion)]
public override string ServerVersion
{
get => GetOpenTdsConnection().ServerVersion;
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ServerProcessId/*' />
[Browsable(false)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_ServerProcessId)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int ServerProcessId
{
get
Expand All @@ -813,6 +860,9 @@ public int ServerProcessId
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/State/*' />
[Browsable(false)]
[ResDescription(StringsHelper.ResourceNames.DbConnection_State)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override ConnectionState State
{
get
Expand All @@ -833,6 +883,9 @@ internal SqlStatistics Statistics
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/WorkstationId/*' />
[ResCategory(StringsHelper.ResourceNames.DataCategory_Data)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_WorkstationId)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string WorkstationId
{
get
Expand All @@ -847,6 +900,9 @@ public string WorkstationId
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/Credential/*' />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[ResDescription(StringsHelper.ResourceNames.SqlConnection_Credential)]
public SqlCredential Credential
{
get
Expand Down Expand Up @@ -977,6 +1033,8 @@ protected override DbProviderFactory DbProviderFactory
//

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/InfoMessage/*' />
[ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_InfoMessage)]
[ResDescription(StringsHelper.ResourceNames.DbConnection_InfoMessage)]
public event SqlInfoMessageEventHandler InfoMessage;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/FireInfoMessageEventOnUserErrors/*' />
Expand Down
Loading

0 comments on commit d1ff708

Please sign in to comment.