diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionString.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionString.netfx.cs index 841369423b..ff6659745a 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionString.netfx.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionString.netfx.cs @@ -326,7 +326,7 @@ private void ValidateCombinedSet(DbConnectionString componentSet, DbConnectionSt HashSet component = new HashSet(componentSet._restrictionValues); combined.ExceptWith(component); Debug.Assert(combined.Count == 0, "Combined set allows values not allowed by component set"); -#endif +#endif } else if (combinedSet._behavior == KeyRestrictionBehavior.PreventUsage) { @@ -350,7 +350,7 @@ private void ValidateCombinedSet(DbConnectionString componentSet, DbConnectionSt HashSet component = new HashSet(componentSet._restrictionValues); combined.IntersectWith(component); Debug.Assert(combined.Count == 0, "Combined values allows values prevented by component set"); -#endif +#endif } else if (combinedSet._behavior == KeyRestrictionBehavior.PreventUsage) { @@ -362,7 +362,7 @@ private void ValidateCombinedSet(DbConnectionString componentSet, DbConnectionSt HashSet component = new HashSet(componentSet._restrictionValues); component.IntersectWith(combined); Debug.Assert(component.Count == 0, "Combined values does not prevent all of the values prevented by the component set"); -#endif +#endif } else { @@ -564,7 +564,7 @@ static internal string[] RemoveDuplicates(string[] restrictions) return restrictions; } - [ConditionalAttribute("DEBUG")] + [Conditional("DEBUG")] private static void Verify(string[] restrictionValues) { if (restrictionValues != null) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs index 4ba8f27d79..e2296b1635 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs @@ -37,7 +37,7 @@ public SqlCommandBuilder(SqlDataAdapter adapter) : this() /// SqlServer only supports CatalogLocation.Start [ Browsable(false), - EditorBrowsableAttribute(EditorBrowsableState.Never), + EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ] public override CatalogLocation CatalogLocation @@ -59,7 +59,7 @@ public override CatalogLocation CatalogLocation /// SqlServer only supports '.' [ Browsable(false), - EditorBrowsableAttribute(EditorBrowsableState.Never), + EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ] public override string CatalogSeparator @@ -80,8 +80,8 @@ public override string CatalogSeparator /// [ DefaultValue(null), - ResCategoryAttribute(nameof(Strings.DataCategory_Update)), - ResDescriptionAttribute(nameof(Strings.SqlCommandBuilder_DataAdapter)), + ResCategory(nameof(Strings.DataCategory_Update)), + ResDescription(nameof(Strings.SqlCommandBuilder_DataAdapter)), ] public new SqlDataAdapter DataAdapter { @@ -99,7 +99,7 @@ public override string CatalogSeparator /// SqlServer only supports '.' [ Browsable(false), - EditorBrowsableAttribute(EditorBrowsableState.Never), + EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ] public override string QuotePrefix @@ -121,7 +121,7 @@ public override string QuotePrefix /// [ Browsable(false), - EditorBrowsableAttribute(EditorBrowsableState.Never), + EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ] public override string QuoteSuffix @@ -143,7 +143,7 @@ public override string QuoteSuffix /// [ Browsable(false), - EditorBrowsableAttribute(EditorBrowsableState.Never), + EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ] public override string SchemaSeparator diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs index aa9d8edc06..8b06a4f90f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -163,19 +163,19 @@ public SqlRetryLogicBaseProvider RetryLogicProvider /// [DefaultValue(null)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Data))] + [ResCategory(nameof(Strings.DataCategory_Data))] [ResDescription(nameof(Strings.TCE_SqlConnection_ColumnEncryptionKeyCacheTtl))] public static TimeSpan ColumnEncryptionKeyCacheTtl { get; set; } = TimeSpan.FromHours(2); /// [DefaultValue(null)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Data))] + [ResCategory(nameof(Strings.DataCategory_Data))] [ResDescription(nameof(Strings.TCE_SqlConnection_ColumnEncryptionQueryMetadataCacheEnabled))] public static bool ColumnEncryptionQueryMetadataCacheEnabled { get; set; } = true; /// [DefaultValue(null)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Data))] + [ResCategory(nameof(Strings.DataCategory_Data))] [ResDescription(nameof(Strings.TCE_SqlConnection_TrustedColumnMasterKeyPaths))] public static IDictionary> ColumnEncryptionTrustedMasterKeyPaths => _ColumnEncryptionTrustedMasterKeyPaths; @@ -265,7 +265,7 @@ private SqlConnection(SqlConnection connection) internal static bool TryGetSystemColumnEncryptionKeyStoreProvider(string keyStoreName, out SqlColumnEncryptionKeyStoreProvider provider) { - return s_systemColumnEncryptionKeyStoreProviders.TryGetValue(keyStoreName, out provider); + return s_systemColumnEncryptionKeyStoreProviders.TryGetValue(keyStoreName, out provider); } /// @@ -508,7 +508,7 @@ private void CacheConnectionStringProperties() // connect the parser to the object. // if there is no parser at this time we need to connect it after creation. [DefaultValue(false)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Data))] + [ResCategory(nameof(Strings.DataCategory_Data))] [ResDescription(nameof(Strings.SqlConnection_StatisticsEnabled))] public bool StatisticsEnabled { @@ -642,9 +642,9 @@ internal int ConnectRetryInterval #pragma warning disable 618 // ignore obsolete warning about RecommendedAsConfigurable to use SettingsBindableAttribute [RecommendedAsConfigurable(true)] #pragma warning restore 618 - [SettingsBindableAttribute(true)] + [SettingsBindable(true)] [RefreshProperties(RefreshProperties.All)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Data))] + [ResCategory(nameof(Strings.DataCategory_Data))] [ResDescription(nameof(Strings.SqlConnection_ConnectionString))] public override string ConnectionString { @@ -1190,7 +1190,7 @@ protected override DbProviderFactory DbProviderFactory // /// - [ResCategoryAttribute(nameof(Strings.DataCategory_InfoMessage))] + [ResCategory(nameof(Strings.DataCategory_InfoMessage))] [ResDescription(nameof(Strings.DbConnection_InfoMessage))] #if NET public event SqlInfoMessageEventHandler InfoMessage; @@ -1320,7 +1320,7 @@ public override void ChangeDatabase(string database) SqlStatistics statistics = null; RepairInnerConnection(); SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlConnection.ChangeDatabase | API | Correlation | Object Id {0}, Activity Id {1}, Database {2}", ObjectID, ActivityCorrelator.Current, database); - + try { statistics = SqlStatistics.StartTimer(Statistics); @@ -1396,7 +1396,7 @@ public override void Close() SqlStatistics statistics = null; Exception e = null; - + try { statistics = SqlStatistics.StartTimer(Statistics); @@ -1889,7 +1889,7 @@ internal void Abort(Exception e) } /// - public override Task OpenAsync(CancellationToken cancellationToken) + public override Task OpenAsync(CancellationToken cancellationToken) => OpenAsync(SqlConnectionOverrides.None, cancellationToken); /// diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index 28c3c965ec..3b07ab0706 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -66,8 +66,8 @@ private SqlDataAdapter(SqlDataAdapter from) : base(from) /// [DefaultValue(null)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Update))] - [ResDescriptionAttribute(nameof(Strings.DbDataAdapter_DeleteCommand))] + [ResCategory(nameof(Strings.DataCategory_Update))] + [ResDescription(nameof(Strings.DbDataAdapter_DeleteCommand))] new public SqlCommand DeleteCommand { get { return _deleteCommand; } @@ -83,8 +83,8 @@ IDbCommand IDbDataAdapter.DeleteCommand /// [DefaultValue(null)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Update))] - [ResDescriptionAttribute(nameof(Strings.DbDataAdapter_InsertCommand))] + [ResCategory(nameof(Strings.DataCategory_Update))] + [ResDescription(nameof(Strings.DbDataAdapter_InsertCommand))] new public SqlCommand InsertCommand { get { return _insertCommand; } @@ -100,8 +100,8 @@ IDbCommand IDbDataAdapter.InsertCommand /// [DefaultValue(null)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Fill))] - [ResDescriptionAttribute(nameof(Strings.DbDataAdapter_SelectCommand))] + [ResCategory(nameof(Strings.DataCategory_Fill))] + [ResDescription(nameof(Strings.DbDataAdapter_SelectCommand))] new public SqlCommand SelectCommand { get { return _selectCommand; } @@ -117,8 +117,8 @@ IDbCommand IDbDataAdapter.SelectCommand /// [DefaultValue(null)] - [ResCategoryAttribute(nameof(Strings.DataCategory_Update))] - [ResDescriptionAttribute(nameof(Strings.DbDataAdapter_UpdateCommand))] + [ResCategory(nameof(Strings.DataCategory_Update))] + [ResDescription(nameof(Strings.DbDataAdapter_UpdateCommand))] new public SqlCommand UpdateCommand { get { return _updateCommand; } @@ -243,8 +243,8 @@ protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, } /// - [ResCategoryAttribute(nameof(Strings.DataCategory_Update))] - [ResDescriptionAttribute(nameof(Strings.DbDataAdapter_RowUpdated))] + [ResCategory(nameof(Strings.DataCategory_Update))] + [ResDescription(nameof(Strings.DbDataAdapter_RowUpdated))] public event SqlRowUpdatedEventHandler RowUpdated { add @@ -258,8 +258,8 @@ public event SqlRowUpdatedEventHandler RowUpdated } /// - [ResCategoryAttribute(nameof(Strings.DataCategory_Update))] - [ResDescriptionAttribute(nameof(Strings.DbDataAdapter_RowUpdating))] + [ResCategory(nameof(Strings.DataCategory_Update))] + [ResDescription(nameof(Strings.DbDataAdapter_RowUpdating))] public event SqlRowUpdatingEventHandler RowUpdating { add diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs index 649c73147c..e316bb3c08 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs @@ -2075,7 +2075,7 @@ override public TextReader GetTextReader(int i) } /// - [EditorBrowsableAttribute(EditorBrowsableState.Never)] + [EditorBrowsable(EditorBrowsableState.Never)] override public char GetChar(int i) { throw ADP.NotSupported(); @@ -2388,7 +2388,7 @@ internal long GetStreamingXmlChars(int i, long dataIndex, char[] buffer, int buf #if NETFRAMEWORK /// - [EditorBrowsableAttribute(EditorBrowsableState.Never)] // MDAC 69508 + [EditorBrowsable(EditorBrowsableState.Never)] // MDAC 69508 IDataReader IDataRecord.GetData(int i) { throw ADP.NotSupported(); diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs index 9304f3051a..836fbb7dd4 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs @@ -236,7 +236,7 @@ public SqlClientObjRef(SqlDependencyProcessDispatcher dispatcher) : base() private List _eventList = new(); private readonly object _eventHandlerLock = new(); // Lock for event serialization. // Track the time that this dependency should time out. If the server didn't send a change - // notification or a time-out before this point then the client will perform a client-side + // notification or a time-out before this point then the client will perform a client-side // timeout. private DateTime _expirationTime = DateTime.MaxValue; // Used for invalidation of dependencies based on which servers they rely upon. @@ -247,8 +247,8 @@ public SqlClientObjRef(SqlDependencyProcessDispatcher dispatcher) : base() private static readonly object s_startStopLock = new(); private static readonly string s_appDomainKey = Guid.NewGuid().ToString(); - // Hashtable containing all information to match from a server, user, database triple to the service started for that - // triple. For each server, there can be N users. For each user, there can be N databases. For each server, user, + // Hashtable containing all information to match from a server, user, database triple to the service started for that + // triple. For each server, there can be N users. For each user, there can be N databases. For each server, user, // database, there can only be one service. private static readonly Dictionary>> s_serverUserHash = new(StringComparer.OrdinalIgnoreCase); @@ -257,7 +257,7 @@ public SqlClientObjRef(SqlDependencyProcessDispatcher dispatcher) : base() // The following two strings are used for AppDomain.CreateInstance. private static readonly string s_assemblyName = (typeof(SqlDependencyProcessDispatcher)).Assembly.FullName; private static readonly string s_typeName = (typeof(SqlDependencyProcessDispatcher)).FullName; -#endif +#endif // EventSource members private static int s_objectTypeCount; // EventSourceCounter counter @@ -266,7 +266,7 @@ public SqlClientObjRef(SqlDependencyProcessDispatcher dispatcher) : base() /// // Constructors #if NETFRAMEWORK - [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] + [HostProtection(ExternalThreading = true)] #endif public SqlDependency() : this(null, null, SQL.SqlDependencyTimeoutDefault) { @@ -274,7 +274,7 @@ public SqlDependency() : this(null, null, SQL.SqlDependencyTimeoutDefault) /// #if NETFRAMEWORK - [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] + [HostProtection(ExternalThreading = true)] #endif public SqlDependency(SqlCommand command) : this(command, null, SQL.SqlDependencyTimeoutDefault) { @@ -313,8 +313,8 @@ public SqlDependency(SqlCommand command, string options, int timeout) /// #if NETFRAMEWORK [ - ResCategoryAttribute(nameof(Strings.DataCategory_Data)), - ResDescriptionAttribute(nameof(Strings.SqlDependency_HasChanges)) + ResCategory(nameof(Strings.DataCategory_Data)), + ResDescription(nameof(Strings.SqlDependency_HasChanges)) ] #endif public bool HasChanges => _dependencyFired; @@ -322,8 +322,8 @@ public SqlDependency(SqlCommand command, string options, int timeout) /// #if NETFRAMEWORK [ - ResCategoryAttribute(nameof(Strings.DataCategory_Data)), - ResDescriptionAttribute(nameof(Strings.SqlDependency_Id)) + ResCategory(nameof(Strings.DataCategory_Data)), + ResDescription(nameof(Strings.SqlDependency_Id)) ] #endif public string Id => _id; @@ -344,8 +344,8 @@ public SqlDependency(SqlCommand command, string options, int timeout) /// #if NETFRAMEWORK [ - ResCategoryAttribute(nameof(Strings.DataCategory_Data)), - ResDescriptionAttribute(nameof(Strings.SqlDependency_OnChange)) + ResCategory(nameof(Strings.DataCategory_Data)), + ResDescription(nameof(Strings.SqlDependency_OnChange)) ] #endif public event OnChangeEventHandler OnChange @@ -422,8 +422,8 @@ public event OnChangeEventHandler OnChange /// #if NETFRAMEWORK [ - ResCategoryAttribute(nameof(Strings.DataCategory_Data)), - ResDescriptionAttribute(nameof(Strings.SqlDependency_AddCommandDependency)) + ResCategory(nameof(Strings.DataCategory_Data)), + ResDescription(nameof(Strings.SqlDependency_AddCommandDependency)) ] #endif public void AddCommandDependency(SqlCommand command) @@ -466,9 +466,9 @@ private static void ObtainProcessDispatcher() #if DEBUG // Possibly expensive, limit to debug. SqlClientEventSource.Log.TryNotificationTraceEvent(" AppDomain.CurrentDomain.FriendlyName: {0}", AppDomain.CurrentDomain.FriendlyName); #endif // DEBUG - + _AppDomain masterDomain = AppDomain.CurrentDomain; - + ObjectHandle handle = CreateProcessDispatcher(masterDomain); if (handle != null) { @@ -484,9 +484,9 @@ private static void ObtainProcessDispatcher() SqlClientObjRef objRef = new(s_processDispatcher); DataContractSerializer serializer = new(objRef.GetType()); GetSerializedObject(objRef, serializer, stream); - + // Native will be forced to synchronize and not overwrite. - SqlDependencyProcessDispatcherStorage.NativeSetData(stream.ToArray()); + SqlDependencyProcessDispatcherStorage.NativeSetData(stream.ToArray()); } } else @@ -914,7 +914,7 @@ private static void RemoveFromServerUserHash(string server, IdentityUserNamePair internal static string GetDefaultComposedOptions(string server, string failoverServer, IdentityUserNamePair identityUser, string database) { - // Server must be an exact match, but user and database only needs to match exactly if there is more than one + // Server must be an exact match, but user and database only needs to match exactly if there is more than one // for the given user or database passed. That is ambiguous and we must fail. long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" server: '{0}', failoverServer: '{1}', database: '{2}'", server, failoverServer, database); try @@ -1014,7 +1014,7 @@ internal static string GetDefaultComposedOptions(string server, string failoverS // Internal Methods - // Called by SqlCommand upon execution of a SqlNotificationRequest class created by this dependency. We + // Called by SqlCommand upon execution of a SqlNotificationRequest class created by this dependency. We // use this list for a reverse lookup based on server. internal void AddToServerList(string server) { diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs index a1735fabe7..d06a02413f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlException.cs @@ -25,15 +25,15 @@ public sealed partial class SqlException : System.Data.Common.DbException private readonly SqlErrorCollection _errors; #if NETFRAMEWORK - [System.Runtime.Serialization.OptionalFieldAttribute(VersionAdded = 4)] + [OptionalField(VersionAdded = 4)] #endif private Guid _clientConnectionId = Guid.Empty; #if NETFRAMEWORK - [System.Runtime.Serialization.IgnoreDataMember] + [IgnoreDataMember] #endif private SqlBatchCommand _batchCommand; #if NETFRAMEWORK - [System.Runtime.Serialization.IgnoreDataMember] + [IgnoreDataMember] #endif // Do not serialize this field! It is used to indicate that no reconnection attempts are required internal bool _doNotReconnect = false; diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs index 80f9540a9a..e79edb9092 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs @@ -15,7 +15,7 @@ // New attributes that are designed to work with Microsoft.Data.SqlClient and are publicly documented should be included in future. namespace Microsoft.Data.SqlClient { - /// + /// [ ListBindable(false) ] @@ -107,8 +107,8 @@ public SqlParameter Add(SqlParameter value) /// public override object SyncRoot => ((System.Collections.ICollection)InnerList).SyncRoot; - /// - [EditorBrowsableAttribute(EditorBrowsableState.Never)] + /// + [EditorBrowsable(EditorBrowsableState.Never)] public override int Add(object value) { IsDirty = true;