diff --git a/bench/.editorconfig b/bench/.editorconfig
index f66bffda880..c86f7f34899 100644
--- a/bench/.editorconfig
+++ b/bench/.editorconfig
@@ -481,11 +481,6 @@ dotnet_diagnostic.CA1507.severity = warning
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
dotnet_diagnostic.CA1508.severity = warning
-# Title : Avoid dead conditional code
-# Category : Maintainability
-# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
-dotnet_diagnostic.CA1508.severity = warning
-
# Title : Invalid entry in code metrics rule specification file
# Category : Maintainability
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1509
diff --git a/eng/Tools/.editorconfig b/eng/Tools/.editorconfig
index be77d5da2f3..8b26ad2938d 100644
--- a/eng/Tools/.editorconfig
+++ b/eng/Tools/.editorconfig
@@ -479,11 +479,6 @@ dotnet_diagnostic.CA1507.severity = warning
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
dotnet_diagnostic.CA1508.severity = warning
-# Title : Avoid dead conditional code
-# Category : Maintainability
-# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
-dotnet_diagnostic.CA1508.severity = warning
-
# Title : Invalid entry in code metrics rule specification file
# Category : Maintainability
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1509
diff --git a/src/Analyzers/.editorconfig b/src/Analyzers/.editorconfig
index c46aa61b062..4f73565695b 100644
--- a/src/Analyzers/.editorconfig
+++ b/src/Analyzers/.editorconfig
@@ -482,11 +482,6 @@ dotnet_diagnostic.CA1507.severity = warning
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
dotnet_diagnostic.CA1508.severity = warning
-# Title : Avoid dead conditional code
-# Category : Maintainability
-# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
-dotnet_diagnostic.CA1508.severity = warning
-
# Title : Invalid entry in code metrics rule specification file
# Category : Maintainability
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1509
diff --git a/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/ApiLifecycleAnalyzer.cs b/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/ApiLifecycleAnalyzer.cs
index 76973c7fc30..6424a114757 100644
--- a/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/ApiLifecycleAnalyzer.cs
+++ b/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/ApiLifecycleAnalyzer.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;
diff --git a/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonObjectExtensions.cs b/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonObjectExtensions.cs
index 27a2e6a5493..0fa9fb224f3 100644
--- a/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonObjectExtensions.cs
+++ b/src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonObjectExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
diff --git a/src/Analyzers/Microsoft.Analyzers.Local/DiagDescriptors.cs b/src/Analyzers/Microsoft.Analyzers.Local/DiagDescriptors.cs
index 46af17c1e0b..ae718238cca 100644
--- a/src/Analyzers/Microsoft.Analyzers.Local/DiagDescriptors.cs
+++ b/src/Analyzers/Microsoft.Analyzers.Local/DiagDescriptors.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using Microsoft.CodeAnalysis;
[assembly: System.Resources.NeutralResourcesLanguage("en-us")]
diff --git a/src/Generators/.editorconfig b/src/Generators/.editorconfig
index c46aa61b062..4f73565695b 100644
--- a/src/Generators/.editorconfig
+++ b/src/Generators/.editorconfig
@@ -482,11 +482,6 @@ dotnet_diagnostic.CA1507.severity = warning
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
dotnet_diagnostic.CA1508.severity = warning
-# Title : Avoid dead conditional code
-# Category : Maintainability
-# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
-dotnet_diagnostic.CA1508.severity = warning
-
# Title : Invalid entry in code metrics rule specification file
# Category : Maintainability
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1509
diff --git a/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs b/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs
index c970caf330f..de0252657b7 100644
--- a/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs
+++ b/src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Method.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using Microsoft.Gen.Logging.Model;
using Microsoft.Gen.Shared;
diff --git a/src/Generators/Microsoft.Gen.Logging/Model/LoggingMethodParameter.cs b/src/Generators/Microsoft.Gen.Logging/Model/LoggingMethodParameter.cs
index 7f90823e9a4..b14ce4dc4e5 100644
--- a/src/Generators/Microsoft.Gen.Logging/Model/LoggingMethodParameter.cs
+++ b/src/Generators/Microsoft.Gen.Logging/Model/LoggingMethodParameter.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Generators/Microsoft.Gen.Logging/Parsing/AttributeProcessors.cs b/src/Generators/Microsoft.Gen.Logging/Parsing/AttributeProcessors.cs
index f20dd59f52b..ab351819b57 100644
--- a/src/Generators/Microsoft.Gen.Logging/Parsing/AttributeProcessors.cs
+++ b/src/Generators/Microsoft.Gen.Logging/Parsing/AttributeProcessors.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using Microsoft.CodeAnalysis;
namespace Microsoft.Gen.Logging.Parsing;
diff --git a/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.LogProperties.cs b/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.LogProperties.cs
index 3a8981c4918..23aebcdb00f 100644
--- a/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.LogProperties.cs
+++ b/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.LogProperties.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
diff --git a/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.Records.cs b/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.Records.cs
index c5f16008de7..484361d7347 100644
--- a/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.Records.cs
+++ b/src/Generators/Microsoft.Gen.Logging/Parsing/Parser.Records.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.CodeAnalysis;
diff --git a/src/LegacySupport/.editorconfig b/src/LegacySupport/.editorconfig
index bc980461f04..757d371f53c 100644
--- a/src/LegacySupport/.editorconfig
+++ b/src/LegacySupport/.editorconfig
@@ -482,11 +482,6 @@ dotnet_diagnostic.CA1507.severity = warning
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
dotnet_diagnostic.CA1508.severity = warning
-# Title : Avoid dead conditional code
-# Category : Maintainability
-# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
-dotnet_diagnostic.CA1508.severity = warning
-
# Title : Invalid entry in code metrics rule specification file
# Category : Maintainability
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1509
diff --git a/src/Libraries/.editorconfig b/src/Libraries/.editorconfig
index b74b979edaf..287246445ae 100644
--- a/src/Libraries/.editorconfig
+++ b/src/Libraries/.editorconfig
@@ -208,7 +208,7 @@ dotnet_code_quality.CA1030.api_surface = public
# Title : Do not catch general exception types
# Category : Design
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1031
-dotnet_diagnostic.CA1031.severity = warning
+dotnet_diagnostic.CA1031.severity = suggestion
# Title : Implement standard exception constructors
# Category : Design
@@ -223,7 +223,7 @@ dotnet_diagnostic.CA1033.severity = warning
# Title : Nested types should not be visible
# Category : Design
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1034
-dotnet_diagnostic.CA1034.severity = warning
+dotnet_diagnostic.CA1034.severity = suggestion
# Title : Override methods on comparable types
# Category : Design
@@ -293,19 +293,19 @@ dotnet_code_quality.CA1052.api_surface = all
# Title : URI-like parameters should not be strings
# Category : Design
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1054
-dotnet_diagnostic.CA1054.severity = warning
+dotnet_diagnostic.CA1054.severity = suggestion
dotnet_code_quality.CA1054.api_surface = public
# Title : URI-like return values should not be strings
# Category : Design
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1055
-dotnet_diagnostic.CA1055.severity = warning
+dotnet_diagnostic.CA1055.severity = suggestion
dotnet_code_quality.CA1055.api_surface = public
# Title : URI-like properties should not be strings
# Category : Design
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1056
-dotnet_diagnostic.CA1056.severity = warning
+dotnet_diagnostic.CA1056.severity = suggestion
dotnet_code_quality.CA1056.api_surface = public
# Title : Types should not extend certain base types
@@ -497,12 +497,7 @@ dotnet_diagnostic.CA1507.severity = warning
# Title : Avoid dead conditional code
# Category : Maintainability
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
-dotnet_diagnostic.CA1508.severity = warning
-
-# Title : Avoid dead conditional code
-# Category : Maintainability
-# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1508
-dotnet_diagnostic.CA1508.severity = warning
+dotnet_diagnostic.CA1508.severity = suggestion
# Title : Invalid entry in code metrics rule specification file
# Category : Maintainability
@@ -578,7 +573,7 @@ dotnet_diagnostic.CA1715.severity = none
# Title : Identifiers should not match keywords
# Category : Naming
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1716
-dotnet_diagnostic.CA1716.severity = warning
+dotnet_diagnostic.CA1716.severity = suggestion
dotnet_code_quality.CA1716.api_surface = all
dotnet_code_quality.CA1716.analyzed_symbol_kinds = all
@@ -1137,7 +1132,7 @@ dotnet_diagnostic.CA2226.severity = none
# Title : Collection properties should be read only
# Category : Usage
# Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2227
-dotnet_diagnostic.CA2227.severity = warning
+dotnet_diagnostic.CA2227.severity = suggestion
# Title : Implement serialization constructors
# Category : Usage
@@ -1783,7 +1778,7 @@ dotnet_diagnostic.EA0001.severity = warning
# Title : Use 'System.TimeProvider' to make the code easier to test
# Category : Reliability
# Help Link: https://aka.ms/dotnet-extensions-warnings/EA0002
-dotnet_diagnostic.EA0002.severity = warning
+dotnet_diagnostic.EA0002.severity = suggestion
# Title : Use the character-based overloads of 'String.StartsWith' or 'String.EndsWith'
# Category : Performance
@@ -1828,7 +1823,7 @@ dotnet_diagnostic.EA0010.severity = warning
# Title : Consider removing unnecessary conditional access operator (?)
# Category : Performance
# Help Link: https://aka.ms/dotnet-extensions-warnings/EA0011
-dotnet_diagnostic.EA0011.severity = warning
+dotnet_diagnostic.EA0011.severity = suggestion
# Title : Consider removing unnecessary null coalescing assignment (??=)
# Category : Performance
@@ -2936,7 +2931,7 @@ dotnet_diagnostic.S101.severity = none
# Title : Lines should not be too long
# Category : Major Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-103
-dotnet_diagnostic.S103.severity = warning
+dotnet_diagnostic.S103.severity = suggestion
# Title : Files should not have too many lines of code
# Category : Major Code Smell
@@ -2968,12 +2963,12 @@ dotnet_diagnostic.S1066.severity = none
# Title : Expressions should not be too complex
# Category : Critical Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-1067
-dotnet_diagnostic.S1067.severity = warning
+dotnet_diagnostic.S1067.severity = suggestion
# Title : Methods should not have too many parameters
# Category : Major Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-107
-dotnet_diagnostic.S107.severity = warning
+dotnet_diagnostic.S107.severity = suggestion
# Title : URIs should not be hardcoded
# Category : Minor Code Smell
@@ -2988,7 +2983,7 @@ dotnet_diagnostic.S108.severity = warning
# Title : Magic numbers should not be used
# Category : Major Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-109
-dotnet_diagnostic.S109.severity = warning
+dotnet_diagnostic.S109.severity = suggestion
# Title : Inheritance tree of classes should not be too deep
# Category : Major Code Smell
@@ -3039,7 +3034,7 @@ dotnet_diagnostic.S112.severity = none
# Title : Assignments should not be made from within sub-expressions
# Category : Major Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-1121
-dotnet_diagnostic.S1121.severity = warning
+dotnet_diagnostic.S1121.severity = suggestion
# Title : "Obsolete" attributes should include explanations
# Category : Major Code Smell
@@ -3288,12 +3283,12 @@ dotnet_diagnostic.S1656.severity = warning
# Title : Multiple variables should not be declared on the same line
# Category : Minor Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-1659
-dotnet_diagnostic.S1659.severity = warning
+dotnet_diagnostic.S1659.severity = suggestion
# Title : An abstract class should have both abstract and concrete methods
# Category : Minor Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-1694
-dotnet_diagnostic.S1694.severity = warning
+dotnet_diagnostic.S1694.severity = suggestion
# Title : NullReferenceException should not be caught
# Category : Major Code Smell
@@ -3380,7 +3375,7 @@ dotnet_diagnostic.S1944.severity = warning
# Title : "for" loop increment clauses should modify the loops' counters
# Category : Critical Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-1994
-dotnet_diagnostic.S1994.severity = warning
+dotnet_diagnostic.S1994.severity = suggestion
# Title : Hashes should include an unpredictable salt
# Category : Critical Vulnerability
@@ -3617,7 +3612,7 @@ dotnet_diagnostic.S2330.severity = warning
# Title : Redundant modifiers should not be used
# Category : Minor Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-2333
-dotnet_diagnostic.S2333.severity = warning
+dotnet_diagnostic.S2333.severity = suggestion
# Title : Public constant members should not be used
# Category : Critical Code Smell
@@ -4021,7 +4016,7 @@ dotnet_diagnostic.S3251.severity = warning
# Title : Constructor and destructor declarations should not be redundant
# Category : Minor Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-3253
-dotnet_diagnostic.S3253.severity = warning
+dotnet_diagnostic.S3253.severity = suggestion
# Title : Default parameter values should not be passed as arguments
# Category : Minor Code Smell
@@ -4104,7 +4099,7 @@ dotnet_diagnostic.S3353.severity = warning
# Title : Ternary operators should not be nested
# Category : Major Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-3358
-dotnet_diagnostic.S3358.severity = warning
+dotnet_diagnostic.S3358.severity = suggestion
# Title : Date and time should not be used as a type for primary keys
# Category : Minor Bug
@@ -4270,7 +4265,7 @@ dotnet_diagnostic.S3603.severity = warning
# Title : Member initializer values should not be redundant
# Category : Minor Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-3604
-dotnet_diagnostic.S3604.severity = warning
+dotnet_diagnostic.S3604.severity = suggestion
# Title : Nullable type comparison should not be redundant
# Category : Major Bug
@@ -4543,7 +4538,7 @@ dotnet_diagnostic.S3995.severity = warning
# Title : URI properties should not be strings
# Category : Major Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-3996
-dotnet_diagnostic.S3996.severity = warning
+dotnet_diagnostic.S3996.severity = suggestion
# Title : String URI overloads should call "System.Uri" overloads
# Category : Major Code Smell
@@ -5201,7 +5196,7 @@ dotnet_diagnostic.S881.severity = suggestion
# Title : "goto" statement should not be used
# Category : Major Code Smell
# Help Link: https://rules.sonarsource.com/csharp/RSPEC-907
-dotnet_diagnostic.S907.severity = warning
+dotnet_diagnostic.S907.severity = suggestion
# Title : Parameter names should match base declaration and other partial definitions
# Category : Critical Code Smell
@@ -5648,12 +5643,12 @@ dotnet_diagnostic.SA1201.severity = none
# Title : Elements should be ordered by access
# Category : StyleCop.CSharp.OrderingRules
# Help Link: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1202.md
-dotnet_diagnostic.SA1202.severity = warning
+dotnet_diagnostic.SA1202.severity = suggestion
# Title : Constants should appear before fields
# Category : StyleCop.CSharp.OrderingRules
# Help Link: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md
-dotnet_diagnostic.SA1203.severity = warning
+dotnet_diagnostic.SA1203.severity = suggestion
# Title : Static elements should appear before instance elements
# Category : StyleCop.CSharp.OrderingRules
@@ -5812,7 +5807,7 @@ dotnet_diagnostic.SA1314.severity = none
# Title : Tuple element names should use correct casing
# Category : StyleCop.CSharp.NamingRules
# Help Link: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1316.md
-dotnet_diagnostic.SA1316.severity = warning
+dotnet_diagnostic.SA1316.severity = suggestion
# Title : Access modifier should be declared
# Category : StyleCop.CSharp.MaintainabilityRules
@@ -6292,7 +6287,7 @@ dotnet_diagnostic.VSTHRD002.severity = warning
# Title : Avoid awaiting foreign Tasks
# Category : Usage
# Help Link: https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD003.md
-dotnet_diagnostic.VSTHRD003.severity = warning
+dotnet_diagnostic.VSTHRD003.severity = suggestion
# Title : Await SwitchToMainThreadAsync
# Category : Usage
@@ -6402,3 +6397,7 @@ dotnet_diagnostic.VSTHRD114.severity = error
# Help Link: https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD200.md
dotnet_diagnostic.VSTHRD200.severity = warning
+# Title : Async method lacks 'await' operators and will run synchronously
+# Category : Reliability
+# Help Link: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1998
+dotnet_diagnostic.CS1998.severity = suggestion
diff --git a/src/Libraries/Microsoft.AspNetCore.AsyncState/TypeWrapper.cs b/src/Libraries/Microsoft.AspNetCore.AsyncState/TypeWrapper.cs
index 83bd97fb515..876ace53876 100644
--- a/src/Libraries/Microsoft.AspNetCore.AsyncState/TypeWrapper.cs
+++ b/src/Libraries/Microsoft.AspNetCore.AsyncState/TypeWrapper.cs
@@ -14,8 +14,6 @@ namespace Microsoft.AspNetCore.AsyncState;
/// Note that is not public, so nobody else can use it.
///
/// The type of the value to store into .
-#pragma warning disable S1694 // Convert this 'abstract' class to a concrete type with protected constructor.
internal abstract class TypeWrapper
-#pragma warning restore S1694 // Convert this 'abstract' class to a concrete type with protected constructor.
{
}
diff --git a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Buffering/PerRequestLogBufferingOptions.cs b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Buffering/PerRequestLogBufferingOptions.cs
index f675466ebe5..5e0cc99f779 100644
--- a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Buffering/PerRequestLogBufferingOptions.cs
+++ b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Buffering/PerRequestLogBufferingOptions.cs
@@ -58,7 +58,6 @@ public class PerRequestLogBufferingOptions
[Range(MinimumPerRequestBufferSizeInBytes, MaximumPerRequestBufferSizeInBytes)]
public int MaxPerRequestBufferSizeInBytes { get; set; } = DefaultPerRequestBufferSizeInBytes;
-#pragma warning disable CA2227 // Collection properties should be read only - setter is necessary for options pattern
///
/// Gets or sets the collection of used for filtering log messages for the purpose of further buffering.
///
@@ -71,6 +70,5 @@ public class PerRequestLogBufferingOptions
/// If a log entry size is greater than , it will not be buffered and will be emitted normally.
///
public IList Rules { get; set; } = [];
-#pragma warning restore CA2227
}
#endif
diff --git a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingRedactionInterceptor.cs b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingRedactionInterceptor.cs
index 31a253f68db..f69b711a206 100644
--- a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingRedactionInterceptor.cs
+++ b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingRedactionInterceptor.cs
@@ -160,7 +160,6 @@ public ValueTask OnResponseAsync(HttpLoggingInterceptorContext logContext)
{
foreach (var enricher in _enrichers)
{
-#pragma warning disable CA1031 // Do not catch general exception types
try
{
enricher.Enrich(loggerMessageState, context);
@@ -169,7 +168,6 @@ public ValueTask OnResponseAsync(HttpLoggingInterceptorContext logContext)
{
_logger.EnricherFailed(ex, enricher.GetType().Name);
}
-#pragma warning restore CA1031 // Do not catch general exception types
}
foreach (var pair in loggerMessageState)
diff --git a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/LoggingRedactionOptions.cs b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/LoggingRedactionOptions.cs
index d2cb34ac547..0310d59a0d7 100644
--- a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/LoggingRedactionOptions.cs
+++ b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/LoggingRedactionOptions.cs
@@ -55,9 +55,7 @@ public class LoggingRedactionOptions
/// If you don't want a parameter to be redacted, mark it as .
///
[Required]
-#pragma warning disable CA2227 // Collection properties should be read only
public IDictionary RouteParameterDataClasses { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase);
-#pragma warning restore CA2227 // Collection properties should be read only
///
/// Gets or sets a map between request headers to be logged and their data classification.
@@ -66,9 +64,7 @@ public class LoggingRedactionOptions
/// The default value is an empty dictionary, which means that no request header is logged by default.
///
[Required]
-#pragma warning disable CA2227 // Collection properties should be read only
public IDictionary RequestHeadersDataClasses { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase);
-#pragma warning restore CA2227 // Collection properties should be read only
///
/// Gets or sets a map between response headers to be logged and their data classification.
@@ -77,9 +73,7 @@ public class LoggingRedactionOptions
/// The default value is an empty dictionary, which means that no response header is logged by default.
///
[Required]
-#pragma warning disable CA2227 // Collection properties should be read only
public IDictionary ResponseHeadersDataClasses { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase);
-#pragma warning restore CA2227 // Collection properties should be read only
///
/// Gets or sets the set of HTTP paths that should be excluded from logging.
@@ -97,9 +91,7 @@ public class LoggingRedactionOptions
/// - "/probe/ready".
///
[Required]
-#pragma warning disable CA2227 // Collection properties should be read only
public ISet ExcludePathStartsWith { get; set; } = new HashSet(StringComparer.OrdinalIgnoreCase);
-#pragma warning restore CA2227 // Collection properties should be read only
///
/// Gets or sets a value indicating whether to report unmatched routes.
diff --git a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/RequestHeadersLogEnricherOptions.cs b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/RequestHeadersLogEnricherOptions.cs
index 81483224810..e18822e7ad5 100644
--- a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/RequestHeadersLogEnricherOptions.cs
+++ b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/RequestHeadersLogEnricherOptions.cs
@@ -23,7 +23,5 @@ public class RequestHeadersLogEnricherOptions
///
[Required]
[Experimental(diagnosticId: DiagnosticIds.Experiments.Telemetry, UrlFormat = DiagnosticIds.UrlFormat)]
-#pragma warning disable CA2227 // Collection properties should be read only
public IDictionary HeadersDataClasses { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase);
-#pragma warning restore CA2227 // Collection properties should be read only
}
diff --git a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParser.cs b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParser.cs
index 34e78e3b37c..22297373047 100644
--- a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParser.cs
+++ b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParser.cs
@@ -10,7 +10,6 @@ namespace Microsoft.AspNetCore.HeaderParsing;
/// Parses raw header value to a header type.
///
/// The resulting strong type representing the header's value.
-[SuppressMessage("Minor Code Smell", "S1694:An abstract class should have both abstract and concrete methods", Justification = "Want abstract class for extensibility and perf")]
public abstract class HeaderParser
where T : notnull
{
@@ -21,6 +20,5 @@ public abstract class HeaderParser
/// A resulting value.
/// An error if parsing failed.
/// Parsing result.
- [SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "There is no such keyword in C#.")]
public abstract bool TryParse(StringValues values, [NotNullWhen(true)] out T? result, [NotNullWhen(false)] out string? error);
}
diff --git a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingFeature.cs b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingFeature.cs
index b3974603efb..915fbbee722 100644
--- a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingFeature.cs
+++ b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingFeature.cs
@@ -114,7 +114,6 @@ private enum BoxState
NotFound = ParsingResult.NotFound,
}
- [SuppressMessage("Minor Code Smell", "S1694:An abstract class should have both abstract and concrete methods", Justification = "Analyzer issue")]
private abstract class Box
{
public abstract void Reset();
diff --git a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptions.cs b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptions.cs
index f8aa8680fb5..2c063d1aa8b 100644
--- a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptions.cs
+++ b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptions.cs
@@ -6,8 +6,6 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.Extensions.Primitives;
-#pragma warning disable CA2227 // Collection properties should be read only
-
namespace Microsoft.AspNetCore.HeaderParsing;
///
diff --git a/src/Libraries/Microsoft.AspNetCore.Testing/FakeSslCertificateFactory.cs b/src/Libraries/Microsoft.AspNetCore.Testing/FakeSslCertificateFactory.cs
index 1a3252df00a..136b6828537 100644
--- a/src/Libraries/Microsoft.AspNetCore.Testing/FakeSslCertificateFactory.cs
+++ b/src/Libraries/Microsoft.AspNetCore.Testing/FakeSslCertificateFactory.cs
@@ -19,7 +19,6 @@ internal static class FakeSslCertificateFactory
/// Creates a self-signed instance for testing.
///
/// An instance for testing.
- [SuppressMessage("Reliability", "EA0002:Use System.TimeProvider when dealing with time in your code.", Justification = "declarations")]
public static X509Certificate2 CreateSslCertificate()
{
var request = new CertificateRequest(
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary.cs
index dab50ff11ee..9bd7d266a6a 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary.cs
@@ -1,10 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S1144 // Unused private types or members should be removed
-#pragma warning disable S2365 // Properties should not make collection or array copies
-#pragma warning disable S3604 // Member initializer values should not be redundant
-
using System.Collections.Generic;
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary{TValue}.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary{TValue}.cs
index 14125e95b76..6b40a6c0d35 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary{TValue}.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary{TValue}.cs
@@ -10,9 +10,6 @@
using System.Linq;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S1144 // Unused private types or members should be removed
-#pragma warning disable S2365 // Properties should not make collection or array copies
-#pragma warning disable S3604 // Member initializer values should not be redundant
#pragma warning disable S4039 // Interface methods should be callable by derived types
#pragma warning disable CA1033 // Interface methods should be callable by derived types
@@ -255,7 +252,9 @@ private sealed class DebugView(AdditionalPropertiesDictionary properties
private readonly AdditionalPropertiesDictionary _properties = Throw.IfNull(properties);
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
+#pragma warning disable S2365 // Properties should not make collection or array copies
public AdditionalProperty[] Items => (from p in _properties select new AdditionalProperty(p.Key, p.Value)).ToArray();
+#pragma warning restore S2365
[DebuggerDisplay("{Value}", Name = "[{Key}]")]
public readonly struct AdditionalProperty(string key, TValue value)
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatMessage.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatMessage.cs
index 7cbbca4e822..4cdf3b30f0a 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatMessage.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatMessage.cs
@@ -7,8 +7,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
-#pragma warning disable S3358 // Ternary operators should not be nested
-
namespace Microsoft.Extensions.AI;
/// Represents a chat message used by an .
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs
index 933c6412c20..81ac83cd59c 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs
@@ -11,9 +11,6 @@
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S109 // Magic numbers should not be used
-#pragma warning disable S1121 // Assignments should not be made from within sub-expressions
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
index 088fc533d05..aaca11c4979 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseFormat.cs
@@ -12,7 +12,6 @@
namespace Microsoft.Extensions.AI;
#pragma warning disable CA1052 // Static holder types should be Static or NotInheritable
-#pragma warning disable S2333 // gratuitous partial
/// Represents the response format that is desired by the caller.
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs
index bea91f97ed9..6a4f11c3777 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs
@@ -7,8 +7,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
-#pragma warning disable S3358 // Ternary operators should not be nested
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs
index 0c11973381b..4b8813c144e 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs
@@ -15,9 +15,6 @@
using System.Text.Json.Serialization;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S3996 // URI properties should not be strings
-#pragma warning disable CA1054 // URI-like parameters should not be strings
-#pragma warning disable CA1056 // URI-like properties should not be strings
#pragma warning disable CA1307 // Specify StringComparison for clarity
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataUriParser.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataUriParser.cs
index cff25e9c30b..6afe1409e75 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataUriParser.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataUriParser.cs
@@ -148,9 +148,7 @@ private static bool IsValidBase64Data(ReadOnlySpan value)
#if NET8_0_OR_GREATER
return Base64.IsValid(value) && !value.ContainsAny(" \t\r\n");
#else
-#pragma warning disable S109 // Magic numbers should not be used
if (value!.Length % 4 != 0)
-#pragma warning restore S109
{
return false;
}
@@ -171,9 +169,7 @@ private static bool IsValidBase64Data(ReadOnlySpan value)
// Now traverse over characters
for (var i = 0; i <= index; i++)
{
-#pragma warning disable S1067 // Expressions should not be too complex
bool validChar = value[i] is (>= 'A' and <= 'Z') or (>= 'a' and <= 'z') or (>= '0' and <= '9') or '+' or '/';
-#pragma warning restore S1067
if (!validChar)
{
return false;
@@ -187,13 +183,11 @@ private static bool IsValidBase64Data(ReadOnlySpan value)
/// Provides the parts of a parsed data URI.
public sealed class DataUri(ReadOnlyMemory data, bool isBase64, string? mediaType)
{
-#pragma warning disable S3604 // False positive: Member initializer values should not be redundant
public string? MediaType { get; } = mediaType;
public ReadOnlyMemory Data { get; } = data;
public bool IsBase64 { get; } = isBase64;
-#pragma warning restore S3604
public byte[] ToByteArray() => IsBase64 ?
Convert.FromBase64String(Data.ToString()) :
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionCallContent.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionCallContent.cs
index d19988b2b76..836d5a4110b 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionCallContent.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionCallContent.cs
@@ -83,7 +83,6 @@ public static FunctionCallContent CreateFromParsedArguments(
IDictionary? arguments = null;
Exception? parsingException = null;
-#pragma warning disable CA1031 // Do not catch general exception types
try
{
arguments = argumentParser(encodedArguments);
@@ -92,7 +91,6 @@ public static FunctionCallContent CreateFromParsedArguments(
{
parsingException = new InvalidOperationException("Error parsing function call arguments.", ex);
}
-#pragma warning restore CA1031 // Do not catch general exception types
return new FunctionCallContent(callId, name, arguments)
{
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs
index 895b7bf7ea7..d4503f57c2b 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs
@@ -8,9 +8,6 @@
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S2302 // "nameof" should be used
-#pragma warning disable S4136 // Method overloads should be grouped together
-
namespace Microsoft.Extensions.AI;
/// Provides a collection of static methods for extending instances.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs
index 88a224ab1c1..9af299013e5 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs
@@ -6,8 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
-#pragma warning disable SA1202 // Elements should be ordered by access
-
namespace Microsoft.Extensions.AI;
/// Represents a function that can be described to an AI service and invoked.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionArguments.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionArguments.cs
index 3238b88e532..4a7c9a555ce 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionArguments.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionArguments.cs
@@ -9,8 +9,6 @@
#pragma warning disable SA1111 // Closing parenthesis should be on line of last parameter
#pragma warning disable SA1112 // Closing parenthesis should be on line of opening parenthesis
#pragma warning disable SA1114 // Parameter list should follow declaration
-#pragma warning disable S3358 // Extract this nested ternary operation into an independent statement.
-#pragma warning disable S1067 // Expressions should not be too complex
#pragma warning disable S4039 // Make 'AIFunctionArguments' sealed
#pragma warning disable CA1033 // Make 'AIFunctionArguments' sealed
#pragma warning disable CA1710 // Identifiers should have correct suffix
@@ -79,14 +77,10 @@ public AIFunctionArguments(IEqualityComparer? comparer)
///
public AIFunctionArguments(IDictionary? arguments, IEqualityComparer? comparer)
{
-#pragma warning disable S1698 // Consider using 'Equals' if value comparison is intended.
_arguments =
- arguments is null
- ? new Dictionary(comparer)
- : (arguments is Dictionary dc) && (comparer is null || dc.Comparer == comparer)
- ? dc
- : new Dictionary(arguments, comparer);
-#pragma warning restore S1698 // Consider using 'Equals' if value comparison is intended.
+ arguments is null ? new(comparer) :
+ arguments is Dictionary dc && (comparer is null || ReferenceEquals(dc.Comparer, comparer)) ? dc :
+ new(arguments, comparer);
}
/// Gets or sets services optionally associated with these arguments.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionDeclaration.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionDeclaration.cs
index e61deb65b82..203045f92b2 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionDeclaration.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionDeclaration.cs
@@ -4,8 +4,6 @@
using System.Text.Json;
using System.Threading.Tasks;
-#pragma warning disable S1694 // An abstract class should have both abstract and concrete methods
-
namespace Microsoft.Extensions.AI;
/// Represents a function that can be described to an AI service.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactory.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactory.cs
index aab33ec19c4..1b804e282dd 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactory.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactory.cs
@@ -22,11 +22,7 @@
using Microsoft.Shared.Collections;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable CA1031 // Do not catch general exception types
-#pragma warning disable S2333 // Redundant modifiers should not be used
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
-#pragma warning disable SA1202 // Public members should come before private members
-#pragma warning disable SA1203 // Constants should appear before fields
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs
index ebb783d35b3..263d1ad6739 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs
@@ -9,8 +9,6 @@
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable SA1202 // Elements should be ordered by access
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunctionDeclaration.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunctionDeclaration.cs
index d113e9539f7..38ebcf0ffd9 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunctionDeclaration.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunctionDeclaration.cs
@@ -6,8 +6,6 @@
using System.Text.Json;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable SA1202 // Elements should be ordered by access
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/HostedMcpServerToolRequireSpecificApprovalMode.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/HostedMcpServerToolRequireSpecificApprovalMode.cs
index 42a39f35c50..267b25334e1 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/HostedMcpServerToolRequireSpecificApprovalMode.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/HostedMcpServerToolRequireSpecificApprovalMode.cs
@@ -6,9 +6,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
-#pragma warning disable S109 // Magic numbers should not be used
-#pragma warning disable EA0011 // Consider removing unnecessary conditional access operator (?)
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Image/ImageGenerationResponse.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Image/ImageGenerationResponse.cs
index 53c33b22978..ba3abe8f1a3 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Image/ImageGenerationResponse.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Image/ImageGenerationResponse.cs
@@ -5,8 +5,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
-#pragma warning disable EA0011 // Consider removing unnecessary conditional access operators
-
namespace Microsoft.Extensions.AI;
/// Represents the result of an image generation request.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.csproj b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.csproj
index f5472854def..661f5d13af6 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.csproj
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.csproj
@@ -1,4 +1,4 @@
-
+
Microsoft.Extensions.AI
@@ -14,7 +14,6 @@
$(TargetFrameworks);netstandard2.0
- $(NoWarn);CA2227;CA1034;SA1316;S3253
$(NoWarn);MEAI001
true
true
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponse.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponse.cs
index 63c6c137411..a63d5cf2d63 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponse.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponse.cs
@@ -7,8 +7,6 @@
using System.Text.Json.Serialization;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable EA0011 // Consider removing unnecessary conditional access operators
-
namespace Microsoft.Extensions.AI;
/// Represents the result of an speech to text request.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdate.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdate.cs
index 24b7f079302..e65dd7dcbe7 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdate.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdate.cs
@@ -7,8 +7,6 @@
using System.Text.Json.Serialization;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable EA0011 // Consider removing unnecessary conditional access operators
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdateExtensions.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdateExtensions.cs
index 0f83a7a8bee..683fdb24f80 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdateExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/SpeechToText/SpeechToTextResponseUpdateExtensions.cs
@@ -7,8 +7,6 @@
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S1121 // Assignments should not be made from within sub-expressions
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs
index 4ab1a1a456f..d8551fe6586 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs
@@ -10,8 +10,6 @@
namespace Microsoft.Extensions.AI;
-#pragma warning disable S1694 // An abstract class should have both abstract and concrete methods
-
/// Represents a tool that can be specified to an AI service.
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public abstract class AITool
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaCreateOptions.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaCreateOptions.cs
index 667b8fee475..9da0d72e5a5 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaCreateOptions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaCreateOptions.cs
@@ -6,8 +6,6 @@
using System.Text.Json.Nodes;
using System.Threading;
-#pragma warning disable S1067 // Expressions should not be too complex
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformCache.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformCache.cs
index 2e3ac758c2f..438c05ce39b 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformCache.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformCache.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text.Json;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformOptions.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformOptions.cs
index 46e7476afcf..101cfa03168 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformOptions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaTransformOptions.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S1067 // Expressions should not be too complex
-
using System;
using System.Text.Json.Nodes;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs
index 986f39d07ef..e905ce93859 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs
@@ -18,10 +18,7 @@
using System.Threading;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S107 // Methods should not have too many parameters
-#pragma warning disable S109 // Magic numbers should not be used
#pragma warning disable S1075 // URIs should not be hardcoded
-#pragma warning disable S1121 // Assignments should not be made from within sub-expressions
#pragma warning disable S1199 // Nested block
#pragma warning disable SA1118 // Parameter should not span multiple lines
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.cs
index 7e28a5983ee..ab66bf61317 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.cs
@@ -17,9 +17,6 @@
#endif
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S109 // Magic numbers should not be used
-#pragma warning disable S1121 // Assignments should not be made from within sub-expressions
-
namespace Microsoft.Extensions.AI;
public static partial class AIJsonUtilities
diff --git a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceChatClient.cs b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceChatClient.cs
index b56604c027d..45081c0ab6c 100644
--- a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceChatClient.cs
@@ -15,7 +15,6 @@
using Azure.AI.Inference;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S1135 // Track uses of "TODO" tags
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
#pragma warning disable SA1204 // Static elements should appear before instance elements
@@ -183,13 +182,6 @@ public async IAsyncEnumerable GetStreamingResponseAsync(
// Transfer over tool call updates.
if (chatCompletionUpdate.ToolCallUpdate is { } toolCallUpdate)
{
- // TODO https://github.com/Azure/azure-sdk-for-net/issues/46830: Azure.AI.Inference
- // has removed the Index property from ToolCallUpdate. It's now impossible via the
- // exposed APIs to correctly handle multiple parallel tool calls, as the CallId is
- // often null for anything other than the first update for a given call, and Index
- // isn't available to correlate which updates are for which call. This is a temporary
- // workaround to at least make a single tool call work and also make work multiple
- // tool calls when their updates aren't interleaved.
if (toolCallUpdate.Id is not null)
{
lastCallId = toolCallUpdate.Id;
@@ -485,8 +477,6 @@ private static IEnumerable ToAzureAIInferenceChatMessages(IE
}
else if (input.Role == ChatRole.Assistant)
{
- // TODO: ChatRequestAssistantMessage only enables text content currently.
- // Update it with other content types when it supports that.
ChatRequestAssistantMessage message = new(string.Concat(input.Contents.Where(c => c is TextContent)));
foreach (var content in input.Contents)
diff --git a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceEmbeddingGenerator.cs b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceEmbeddingGenerator.cs
index 95cea4e2a3b..04383a85b86 100644
--- a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceEmbeddingGenerator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceEmbeddingGenerator.cs
@@ -15,9 +15,7 @@
using Azure.AI.Inference;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable EA0002 // Use 'System.TimeProvider' to make the code easier to test
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
-#pragma warning disable S109 // Magic numbers should not be used
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceImageEmbeddingGenerator.cs b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceImageEmbeddingGenerator.cs
index 91222722b2a..b04a7c73a39 100644
--- a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceImageEmbeddingGenerator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceImageEmbeddingGenerator.cs
@@ -11,9 +11,7 @@
using Azure.AI.Inference;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable EA0002 // Use 'System.TimeProvider' to make the code easier to test
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
-#pragma warning disable S109 // Magic numbers should not be used
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/Microsoft.Extensions.AI.AzureAIInference.csproj b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/Microsoft.Extensions.AI.AzureAIInference.csproj
index 06690c96eaf..3dc80561205 100644
--- a/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/Microsoft.Extensions.AI.AzureAIInference.csproj
+++ b/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/Microsoft.Extensions.AI.AzureAIInference.csproj
@@ -1,4 +1,4 @@
-
+
Microsoft.Extensions.AI
@@ -15,7 +15,7 @@
$(TargetFrameworks);netstandard2.0
- $(NoWarn);CA1063;CA2227;SA1316;S1067;S1121;S3358
+ $(NoWarn);CA1063
true
true
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/BLEUEvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/BLEUEvaluatorContext.cs
index c1eaf699565..702b47948ed 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/BLEUEvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/BLEUEvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/Common/SimpleWordTokenizer.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/Common/SimpleWordTokenizer.cs
index 322ea4cedd6..46ae984cb9d 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/Common/SimpleWordTokenizer.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/Common/SimpleWordTokenizer.cs
@@ -6,8 +6,6 @@
using System.Text;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S109 // Magic numbers should not be used
-
namespace Microsoft.Extensions.AI.Evaluation.NLP.Common;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/F1EvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/F1EvaluatorContext.cs
index d6dafcc3c6a..ff2091d9dc5 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/F1EvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/F1EvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation.NLP;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/GLEUEvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/GLEUEvaluatorContext.cs
index d98aac6811d..dd5a75d439d 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/GLEUEvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.NLP/GLEUEvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CoherenceEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CoherenceEvaluator.cs
index 7bf68d887c9..7617c6ee2d0 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CoherenceEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CoherenceEvaluator.cs
@@ -104,7 +104,6 @@ await TimingHelper.ExecuteWithTimingAsync(() =>
private static List GetEvaluationInstructions(ChatMessage? userRequest, ChatResponse modelResponse)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
# Instruction
@@ -114,14 +113,12 @@ private static List GetEvaluationInstructions(ChatMessage? userRequ
- **Data**: Your input data include a QUERY and a RESPONSE.
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
string renderedUserRequest = userRequest?.RenderText() ?? string.Empty;
string renderedModelResponse = modelResponse.RenderText();
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
# Definition
@@ -194,7 +191,6 @@ private static List GetEvaluationInstructions(ChatMessage? userRequ
## Please provide your answers between the tags: your chain of thoughts, your explanation, your Score.
# Output
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluator.cs
index 20a0b7b58b3..b398ca7b4aa 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluator.cs
@@ -112,7 +112,6 @@ private static List GetEvaluationInstructions(
ChatResponse modelResponse,
CompletenessEvaluatorContext context)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
# Instruction
@@ -122,14 +121,12 @@ private static List GetEvaluationInstructions(
- **Data**: Your input data include Response and Ground Truth.
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
string renderedModelResponse = modelResponse.RenderText();
string groundTruth = context.GroundTruth;
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
# Definition
@@ -186,7 +183,6 @@ private static List GetEvaluationInstructions(
## Please provide your answers between the tags: your chain of thoughts, your explanation, your score.
# Output
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluatorContext.cs
index b9750da0a4d..8c7bf5d55e3 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/CompletenessEvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation.Quality;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluator.cs
index e166f573573..e3f34d75982 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluator.cs
@@ -114,12 +114,10 @@ private static List GetEvaluationInstructions(
ChatResponse modelResponse,
EquivalenceEvaluatorContext context)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
You are an AI assistant. You will be given the definition of an evaluation metric for assessing the quality of an answer in a question-answering task. Your job is to compute an accurate evaluation score using the provided evaluation metric. You should return a single integer value between 1 to 5 representing the evaluation metric. You will include no other text or information.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
@@ -127,7 +125,6 @@ private static List GetEvaluationInstructions(
string renderedModelResponse = modelResponse.RenderText();
string groundTruth = context.GroundTruth;
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
Equivalence, as a metric, measures the similarity between the predicted answer and the correct answer. If the information and content in the predicted answer is similar or equivalent to the correct answer, then the value of the Equivalence metric should be high, else it should be low. Given the question, correct answer, and predicted answer, determine the value of Equivalence metric using the following rating scale:
@@ -171,7 +168,6 @@ This rating value should always be an integer between 1 and 5. So the rating pro
predicted answer: {{renderedModelResponse}}
stars:
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluatorContext.cs
index 31718bacfbf..b45b5b8bbe3 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/EquivalenceEvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation.Quality;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/FluencyEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/FluencyEvaluator.cs
index 97a7a651427..41149bafe20 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/FluencyEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/FluencyEvaluator.cs
@@ -96,7 +96,6 @@ await TimingHelper.ExecuteWithTimingAsync(() =>
private static List GetEvaluationInstructions(ChatResponse modelResponse)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
# Instruction
@@ -106,13 +105,11 @@ private static List GetEvaluationInstructions(ChatResponse modelRes
- **Data**: Your input data include a RESPONSE.
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
string renderedModelResponse = modelResponse.RenderText();
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
# Definition
@@ -174,7 +171,6 @@ private static List GetEvaluationInstructions(ChatResponse modelRes
## Please provide your answers between the tags: your chain of thoughts, your explanation, your Score.
# Output
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluator.cs
index 080fb9262f2..706655620e5 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluator.cs
@@ -114,7 +114,6 @@ private static List GetEvaluationInstructions(
ChatResponse modelResponse,
GroundednessEvaluatorContext context)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
# Instruction
@@ -124,14 +123,12 @@ private static List GetEvaluationInstructions(
- **Data**: Your input data include CONTEXT, RESPONSE and an optional QUERY.
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
string renderedModelResponse = modelResponse.RenderText();
string groundingContext = context.GroundingContext;
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt;
if (userRequest is null)
{
@@ -296,7 +293,6 @@ private static List GetEvaluationInstructions(
# Output
""";
}
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluatorContext.cs
index a1c41989f44..d637c4d1ac9 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/GroundednessEvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation.Quality;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionEvaluator.cs
index 5741adaff66..bce372e467c 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionEvaluator.cs
@@ -176,7 +176,6 @@ private static List GetEvaluationInstructions(
string renderedModelResponse = modelResponse.RenderAsJson();
string? renderedToolDefinitions = context?.ToolDefinitions.RenderAsJson();
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
# Goal
@@ -313,7 +312,6 @@ Note that the QUERY can either be a string with a user request or an entire conv
# Output
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionRating.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionRating.cs
index a1d9b0ef90e..c7eb8791f75 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionRating.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionRating.cs
@@ -55,7 +55,6 @@ internal sealed class IntentResolutionRating
public bool IsInconclusive => ResolutionScore < MinValue || ResolutionScore > MaxValue;
[JsonConstructor]
-#pragma warning disable S107 // Methods should not have too many parameters
public IntentResolutionRating(
int resolutionScore,
string explanation,
@@ -64,7 +63,6 @@ public IntentResolutionRating(
bool conversationHasIntent,
bool correctIntentDetected,
bool intentResolved)
-#pragma warning restore S107
{
ResolutionScore = resolutionScore;
Explanation = explanation;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceEvaluator.cs
index 46f48d13ab8..31f7a68d510 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceEvaluator.cs
@@ -109,7 +109,6 @@ await TimingHelper.ExecuteWithTimingAsync(() =>
private static List GetEvaluationInstructions(ChatMessage userRequest, ChatResponse modelResponse)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
# Instruction
@@ -119,14 +118,12 @@ private static List GetEvaluationInstructions(ChatMessage userReque
- **Data**: Your input data include QUERY and RESPONSE.
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
string renderedUserRequest = userRequest.RenderText();
string renderedModelResponse = modelResponse.RenderText();
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
# Definition
@@ -200,7 +197,6 @@ private static List GetEvaluationInstructions(ChatMessage userReque
## Please provide your answers between the tags: your chain of thoughts, your explanation, your Score.
# Output
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessEvaluator.cs
index d175bfa7852..a41f7a92824 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessEvaluator.cs
@@ -143,7 +143,6 @@ private static List GetEvaluationInstructions(
string renderedModelResponse = modelResponse.RenderText();
string renderedConversationHistory = conversationHistory.RenderText();
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
Read the History, User Query, and Model Response below and produce your response as a single JSON object.
@@ -263,7 +262,6 @@ Step 3a. Record your response as the value of the "completeness" property in the
-----
""";
-#pragma warning restore S103
return [new ChatMessage(ChatRole.User, evaluationPrompt)];
}
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessRating.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessRating.cs
index 83c76a1825e..8d4cd88fb5a 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessRating.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessRating.cs
@@ -53,20 +53,16 @@ internal sealed class RelevanceTruthAndCompletenessRating
private const int MinValue = 1;
private const int MaxValue = 5;
-#pragma warning disable S1067 // Expressions should not be too complex.
public bool IsInconclusive =>
Relevance < MinValue || Relevance > MaxValue ||
Truth < MinValue || Truth > MaxValue ||
Completeness < MinValue || Completeness > MaxValue;
-#pragma warning restore S1067
[JsonConstructor]
-#pragma warning disable S107 // Methods should not have too many parameters.
public RelevanceTruthAndCompletenessRating(
int relevance, string relevanceReasoning, string[] relevanceReasons,
int truth, string truthReasoning, string[] truthReasons,
int completeness, string completenessReasoning, string[] completenessReasons)
-#pragma warning restore S107
{
(Relevance, RelevanceReasoning, RelevanceReasons,
Truth, TruthReasoning, TruthReasons,
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RetrievalEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RetrievalEvaluator.cs
index 557f66b0d21..7bd776f2db6 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RetrievalEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RetrievalEvaluator.cs
@@ -128,7 +128,6 @@ private static List GetEvaluationInstructions(
ChatMessage userRequest,
RetrievalEvaluatorContext context)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
# Instruction
@@ -138,7 +137,6 @@ private static List GetEvaluationInstructions(
- **Data**: Your input data include QUERY and CONTEXT.
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
@@ -158,7 +156,6 @@ private static List GetEvaluationInstructions(
_ = builder.Append(']');
string renderedContext = builder.ToString();
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
# Definition
@@ -225,7 +222,6 @@ private static List GetEvaluationInstructions(
## Please provide your answers between the tags: your chain of thoughts, your explanation, your Score.
# Output
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/TaskAdherenceEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/TaskAdherenceEvaluator.cs
index c9e189af365..5f447138312 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/TaskAdherenceEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/TaskAdherenceEvaluator.cs
@@ -166,7 +166,6 @@ private static List GetEvaluationInstructions(
string renderedModelResponse = modelResponse.RenderAsJson();
string? renderedToolDefinitions = context?.ToolDefinitions.RenderAsJson();
-#pragma warning disable S103 // Lines should not be too long
string systemPrompt =
$$"""
# Instruction
@@ -261,7 +260,6 @@ Response meets the core requirements but lacks precision or clarity.
## Please provide your answers between the tags: your chain of thoughts, your explanation, your score.
# Output
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, systemPrompt)];
return evaluationInstructions;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/ToolCallAccuracyEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/ToolCallAccuracyEvaluator.cs
index 252b1254354..05dbf4bbc1d 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/ToolCallAccuracyEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/ToolCallAccuracyEvaluator.cs
@@ -157,7 +157,6 @@ private static List GetEvaluationInstructions(
ChatResponse modelResponse,
ToolCallAccuracyEvaluatorContext context)
{
-#pragma warning disable S103 // Lines should not be too long
const string SystemPrompt =
"""
# Instruction
@@ -167,7 +166,6 @@ private static List GetEvaluationInstructions(
- **Data**: Your input data include CONVERSATION , TOOL CALL and TOOL DEFINITION.
- **Tasks**: To complete your evaluation you will be asked to evaluate the Data in different ways.
""";
-#pragma warning restore S103
List evaluationInstructions = [new ChatMessage(ChatRole.System, SystemPrompt)];
@@ -175,7 +173,6 @@ private static List GetEvaluationInstructions(
string renderedToolCallsAndResults = modelResponse.RenderToolCallsAndResultsAsJson();
string renderedToolDefinitions = context.ToolDefinitions.RenderAsJson();
-#pragma warning disable S103 // Lines should not be too long
string evaluationPrompt =
$$"""
# Definition
@@ -218,7 +215,6 @@ 3. TOOL CALL has parameters that is present in TOOL DEFINITION.
## Please provide your answers between the tags: your chain of thoughts, your explanation, your Score.
# Output
""";
-#pragma warning restore S103
evaluationInstructions.Add(new ChatMessage(ChatRole.User, evaluationPrompt));
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/JsonSerialization/AzureStorageJsonUtilities.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/JsonSerialization/AzureStorageJsonUtilities.cs
index b36c8d8bd56..204ac68394b 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/JsonSerialization/AzureStorageJsonUtilities.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/JsonSerialization/AzureStorageJsonUtilities.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Diagnostics.CodeAnalysis;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -12,7 +11,6 @@ namespace Microsoft.Extensions.AI.Evaluation.Reporting.JsonSerialization;
internal static partial class AzureStorageJsonUtilities
{
- [SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "Default matches the generated source naming convention.")]
internal static class Default
{
private static JsonSerializerOptions? _options;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Microsoft.Extensions.AI.Evaluation.Reporting.Azure.csproj b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Microsoft.Extensions.AI.Evaluation.Reporting.Azure.csproj
index 77ed508757c..ddc986f187a 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Microsoft.Extensions.AI.Evaluation.Reporting.Azure.csproj
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Microsoft.Extensions.AI.Evaluation.Reporting.Azure.csproj
@@ -4,8 +4,6 @@
A library that supports the Microsoft.Extensions.AI.Evaluation.Reporting library with an implementation for caching LLM responses and storing the evaluation results in an Azure Storage container.
$(TargetFrameworks);netstandard2.0
Microsoft.Extensions.AI.Evaluation.Reporting
-
- $(NoWarn);EA0002
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageReportingConfiguration.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageReportingConfiguration.cs
index 3131fc1c5d9..197d795e742 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageReportingConfiguration.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageReportingConfiguration.cs
@@ -66,7 +66,6 @@ public static class AzureStorageReportingConfiguration
/// (persisted to the cache using older versions of the library) will no longer be used - instead new responses
/// will be fetched from the LLM and added to the cache for use in subsequent executions.
///
-#pragma warning disable S107 // Methods should not have too many parameters
public static ReportingConfiguration Create(
DataLakeDirectoryClient client,
IEnumerable evaluators,
@@ -77,7 +76,6 @@ public static ReportingConfiguration Create(
string executionName = Defaults.DefaultExecutionName,
Func? evaluationMetricInterpreter = null,
IEnumerable? tags = null)
-#pragma warning restore S107
{
IEvaluationResponseCacheProvider? responseCacheProvider =
chatConfiguration is not null && enableResponseCaching
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.CacheEntry.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.CacheEntry.cs
index c40c4bafcf1..eedf15d75ba 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.CacheEntry.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.CacheEntry.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Globalization;
using System.IO;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.cs
index 5e83b456a0b..05f4f01eeaf 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCache.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
#pragma warning disable CA1725
// CA1725: Parameter names should match base declaration.
// All functions on 'IDistributedCache' use the parameter name 'token' in place of 'cancellationToken'. However,
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCacheProvider.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCacheProvider.cs
index 6c6d1431a1a..3507bd3769e 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCacheProvider.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResponseCacheProvider.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatDetails.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatDetails.cs
index 623485a8460..744a1098560 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatDetails.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatDetails.cs
@@ -13,17 +13,11 @@ namespace Microsoft.Extensions.AI.Evaluation.Reporting;
///
public sealed class ChatDetails
{
-#pragma warning disable CA2227
- // CA2227: Collection properties should be read only.
- // We disable this warning because we want this type to be fully mutable for serialization purposes and for general
- // convenience.
-
///
/// Gets or sets the for the LLM chat conversation turns recorded in this
/// object.
///
public IList TurnDetails { get; set; }
-#pragma warning restore CA2227
///
/// Initializes a new instance of the class.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatTurnDetails.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatTurnDetails.cs
index f9c93995224..2b1ad34e1ca 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatTurnDetails.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ChatTurnDetails.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Text.Json.Serialization;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Formats/Dataset.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Formats/Dataset.cs
index 1fb8b6c5ec9..146d3ae999b 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Formats/Dataset.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Formats/Dataset.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/JsonSerialization/JsonUtilities.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/JsonSerialization/JsonUtilities.cs
index 3a8c2af1ce2..fb514bd33c8 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/JsonSerialization/JsonUtilities.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/JsonSerialization/JsonUtilities.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Diagnostics.CodeAnalysis;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -13,7 +12,6 @@ namespace Microsoft.Extensions.AI.Evaluation.Reporting.JsonSerialization;
internal static partial class JsonUtilities
{
- [SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "Default matches the generated source naming convention.")]
internal static class Default
{
private static JsonSerializerOptions? _options;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Microsoft.Extensions.AI.Evaluation.Reporting.csproj b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Microsoft.Extensions.AI.Evaluation.Reporting.csproj
index 77a492d154f..8ee31bc2b1a 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Microsoft.Extensions.AI.Evaluation.Reporting.csproj
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Microsoft.Extensions.AI.Evaluation.Reporting.csproj
@@ -11,8 +11,6 @@
A library that contains support for caching LLM responses, storing the results of evaluations and generating reports from that data.
$(TargetFrameworks);netstandard2.0
Microsoft.Extensions.AI.Evaluation.Reporting
-
- $(NoWarn);EA0002
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ReportingConfiguration.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ReportingConfiguration.cs
index 2f6613bbcbc..e74ca096f2c 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ReportingConfiguration.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ReportingConfiguration.cs
@@ -132,7 +132,6 @@ public sealed class ReportingConfiguration
/// A optional set of text tags applicable to all s created using this
/// .
///
-#pragma warning disable S107 // Methods should not have too many parameters
public ReportingConfiguration(
IEnumerable evaluators,
IEvaluationResultStore resultStore,
@@ -142,7 +141,6 @@ public ReportingConfiguration(
string executionName = Defaults.DefaultExecutionName,
Func? evaluationMetricInterpreter = null,
IEnumerable? tags = null)
-#pragma warning restore S107
{
Evaluators = [.. evaluators];
ResultStore = resultStore;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRun.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRun.cs
index 5fa46e7e4ec..80ca411edb3 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRun.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRun.cs
@@ -100,7 +100,6 @@ public sealed class ScenarioRun : IAsyncDisposable
private ScenarioRunResult? _result;
-#pragma warning disable S107 // Methods should not have too many parameters
internal ScenarioRun(
string scenarioName,
string iterationName,
@@ -111,7 +110,6 @@ internal ScenarioRun(
Func? evaluationMetricInterpreter = null,
ChatDetails? chatDetails = null,
IEnumerable? tags = null)
-#pragma warning restore
{
ScenarioName = scenarioName;
IterationName = iterationName;
@@ -150,10 +148,8 @@ public async ValueTask EvaluateAsync(
{
if (_result is not null)
{
-#pragma warning disable S103 // Lines should not be too long
throw new InvalidOperationException(
$"The {nameof(ScenarioRun)} with {nameof(ScenarioName)}: {ScenarioName}, {nameof(IterationName)}: {IterationName} and {nameof(ExecutionName)}: {ExecutionName} has already been evaluated. Do not call {nameof(EvaluateAsync)} more than once on a given {nameof(ScenarioRun)}.");
-#pragma warning restore S103
}
EvaluationResult evaluationResult =
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRunResult.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRunResult.cs
index af2c1d08a4c..e851a48dfdd 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRunResult.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRunResult.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
@@ -126,17 +121,11 @@ public ScenarioRunResult(
///
public DateTime CreationTime { get; set; } = creationTime;
-#pragma warning disable CA2227
- // CA2227: Collection properties should be read only.
- // We disable this warning because we want this type to be fully mutable for serialization purposes and for general
- // convenience.
-
///
/// Gets or sets the conversation history including the request that produced the being
/// evaluated in this .
///
public IList Messages { get; set; } = messages;
-#pragma warning restore CA2227
///
/// Gets or sets the response being evaluated in this .
@@ -165,16 +154,10 @@ public ScenarioRunResult(
///
public ChatDetails? ChatDetails { get; set; } = chatDetails;
-#pragma warning disable CA2227
- // CA2227: Collection properties should be read only.
- // We disable this warning because we want this type to be fully mutable for serialization purposes and for general
- // convenience.
-
///
/// Gets or sets a set of text tags applicable to this .
///
public IList? Tags { get; set; } = tags;
-#pragma warning restore CA2227
///
/// Gets or sets the version of the format used to persist the current .
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedReportingConfiguration.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedReportingConfiguration.cs
index 10350446229..ad28389aa30 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedReportingConfiguration.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedReportingConfiguration.cs
@@ -66,7 +66,6 @@ public static class DiskBasedReportingConfiguration
/// (persisted to the cache using older versions of the library) will no longer be used - instead new responses
/// will be fetched from the LLM and added to the cache for use in subsequent executions.
///
-#pragma warning disable S107 // Methods should not have too many parameters
public static ReportingConfiguration Create(
string storageRootPath,
IEnumerable evaluators,
@@ -77,7 +76,6 @@ public static ReportingConfiguration Create(
string executionName = Defaults.DefaultExecutionName,
Func? evaluationMetricInterpreter = null,
IEnumerable? tags = null)
-#pragma warning restore S107
{
storageRootPath = Path.GetFullPath(storageRootPath);
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.CacheEntry.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.CacheEntry.cs
index 6d5000c0395..12ac20923ee 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.CacheEntry.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.CacheEntry.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Globalization;
using System.IO;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.cs
index d0a107d8710..3d2e53a9ff4 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCache.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
#pragma warning disable CA1725
// CA1725: Parameter names should match base declaration.
// All functions on 'IDistributedCache' use the parameter name 'token' in place of 'cancellationToken'. However,
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCacheProvider.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCacheProvider.cs
index 8b60fe5a272..cfbdb207c0c 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCacheProvider.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResponseCacheProvider.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResultStore.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResultStore.cs
index 4662857ec59..72bed04f2cd 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResultStore.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Storage/DiskBasedResultStore.cs
@@ -177,11 +177,9 @@ public ValueTask DeleteResultsAsync(
}
///
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously.
public async IAsyncEnumerable GetLatestExecutionNamesAsync(
int? count = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
-#pragma warning restore CS1998
{
if (count.HasValue && count <= 0)
{
@@ -204,11 +202,9 @@ public async IAsyncEnumerable GetLatestExecutionNamesAsync(
}
///
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously.
public async IAsyncEnumerable GetScenarioNamesAsync(
string executionName,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
-#pragma warning restore CS1998
{
IEnumerable executionDirs = EnumerateExecutionDirs(executionName, cancellationToken);
@@ -224,12 +220,10 @@ public async IAsyncEnumerable GetScenarioNamesAsync(
}
///
-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously.
public async IAsyncEnumerable GetIterationNamesAsync(
string executionName,
string scenarioName,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
-#pragma warning restore CS1998
{
IEnumerable resultFiles =
EnumerateResultFiles(executionName, scenarioName, cancellationToken: cancellationToken);
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatClient.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatClient.cs
index 1669bb7df6b..01618997069 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatClient.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatOptions.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatOptions.cs
index 741bca9f790..2b95d3b5f39 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatOptions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyChatOptions.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation.Safety;
internal sealed class ContentSafetyChatOptions(string annotationTask, string evaluatorName) : ChatOptions
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyEvaluator.cs
index 9c562c6f80c..d5414f47741 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyEvaluator.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Collections.Generic;
using System.Linq;
@@ -30,11 +25,9 @@ namespace Microsoft.Extensions.AI.Evaluation.Safety;
/// AI Foundry Evaluation service, to the s of the s
/// returned by this .
///
-#pragma warning disable S1694 // An abstract class should have both abstract and concrete methods
public abstract class ContentSafetyEvaluator(
string contentSafetyServiceAnnotationTask,
IDictionary metricNames) : IEvaluator
-#pragma warning restore S1694
{
///
public IReadOnlyCollection EvaluationMetricNames { get; } = [.. metricNames.Values];
@@ -115,13 +108,11 @@ protected async ValueTask EvaluateContentSafetyAsync(
{
IReadOnlyList? relevantContext = FilterAdditionalContext(additionalContext);
-#pragma warning disable S1067 // Expressions should not be too complex
if (relevantContext is not null && relevantContext.Any() &&
relevantContext.SelectMany(c => c.Contents) is IEnumerable contents && contents.Any() &&
contents.OfType() is IEnumerable textContents && textContents.Any() &&
string.Join(Environment.NewLine, textContents.Select(c => c.Text)) is string contextString &&
!string.IsNullOrWhiteSpace(contextString))
-#pragma warning restore S1067
{
// Currently we only support supplying a context for the last conversation turn (which is the main one
// that is being evaluated).
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.UrlCacheKey.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.UrlCacheKey.cs
index c8969a001c4..9454cb7f0e4 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.UrlCacheKey.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.UrlCacheKey.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
namespace Microsoft.Extensions.AI.Evaluation.Safety;
@@ -18,27 +13,16 @@ private sealed class UrlCacheKey(ContentSafetyServiceConfiguration configuration
internal ContentSafetyServiceConfiguration Configuration { get; } = configuration;
internal string AnnotationTask { get; } = annotationTask;
- public bool Equals(UrlCacheKey? other)
- {
- if (other is null)
- {
- return false;
- }
- else
- {
-#pragma warning disable S1067 // Expressions should not be too complex
- return
- other.Configuration.SubscriptionId == Configuration.SubscriptionId &&
- other.Configuration.ResourceGroupName == Configuration.ResourceGroupName &&
- other.Configuration.ProjectName == Configuration.ProjectName &&
- other.Configuration.Endpoint == Configuration.Endpoint &&
- other.AnnotationTask == AnnotationTask;
-#pragma warning restore S1067
- }
- }
+ public bool Equals(UrlCacheKey? other) =>
+ other is not null &&
+ other.Configuration.SubscriptionId == Configuration.SubscriptionId &&
+ other.Configuration.ResourceGroupName == Configuration.ResourceGroupName &&
+ other.Configuration.ProjectName == Configuration.ProjectName &&
+ other.Configuration.Endpoint == Configuration.Endpoint &&
+ other.AnnotationTask == AnnotationTask;
- public override bool Equals(object? other)
- => other is UrlCacheKey otherKey && Equals(otherKey);
+ public override bool Equals(object? other) =>
+ other is UrlCacheKey otherKey && Equals(otherKey);
public override int GetHashCode() =>
HashCode.Combine(
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.cs
index ee9bdf2c926..ec3dc720bb0 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
@@ -392,9 +387,7 @@ await GetResponseAsync(
}
else
{
-#pragma warning disable EA0002 // Use 'System.TimeProvider' to make the code easier to test
await Task.Delay(InitialDelayInMilliseconds * attempts, cancellationToken).ConfigureAwait(false);
-#pragma warning restore EA0002
}
}
}
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServiceConfiguration.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServiceConfiguration.cs
index 56c6f3cc0f0..3e814f430e3 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServiceConfiguration.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServiceConfiguration.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServicePayloadUtilities.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServicePayloadUtilities.cs
index feecec3be46..1d2f0768a1f 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServicePayloadUtilities.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyServicePayloadUtilities.cs
@@ -74,7 +74,6 @@ internal static (string payload, IReadOnlyList? diagnostic
_ => throw new NotSupportedException($"The payload kind '{payloadFormat}' is not supported."),
};
-#pragma warning disable S107 // Methods should not have too many parameters
private static (string payload, IReadOnlyList? diagnostics)
GetUserTextListPayloadWithEmbeddedXml(
IEnumerable conversation,
@@ -87,7 +86,6 @@ private static (string payload, IReadOnlyList? diagnostics
string contextElementName = "Context",
ContentSafetyServicePayloadStrategy strategy = ContentSafetyServicePayloadStrategy.AnnotateConversation,
CancellationToken cancellationToken = default)
-#pragma warning restore S107
{
List> turns;
List? normalizedPerTurnContext;
@@ -162,7 +160,6 @@ private static (string payload, IReadOnlyList? diagnostics
return (payload.ToJsonString(), diagnostics);
}
-#pragma warning disable S107 // Methods should not have too many parameters
private static (string payload, IReadOnlyList? diagnostics)
GetUserTextListPayloadWithEmbeddedJson(
IEnumerable conversation,
@@ -175,7 +172,6 @@ private static (string payload, IReadOnlyList? diagnostics
string contextPropertyName = "context",
ContentSafetyServicePayloadStrategy strategy = ContentSafetyServicePayloadStrategy.AnnotateLastTurn,
CancellationToken cancellationToken = default)
-#pragma warning restore S107
{
if (strategy is ContentSafetyServicePayloadStrategy.AnnotateConversation)
{
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/GroundednessProEvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/GroundednessProEvaluatorContext.cs
index 677fd4154b3..56af247350d 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/GroundednessProEvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/GroundednessProEvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation.Safety;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/UngroundedAttributesEvaluatorContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/UngroundedAttributesEvaluatorContext.cs
index b3273b93798..ef72729f6bb 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/UngroundedAttributesEvaluatorContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/UngroundedAttributesEvaluatorContext.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation.Safety;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/ChatConfiguration.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/ChatConfiguration.cs
index 881816b198b..0d1db0ed487 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/ChatConfiguration.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/ChatConfiguration.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/CompositeEvaluator.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/CompositeEvaluator.cs
index e3d0fad4caf..07e2636d7f9 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/CompositeEvaluator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/CompositeEvaluator.cs
@@ -50,10 +50,8 @@ public CompositeEvaluator(IEnumerable evaluators)
{
if (evaluator.EvaluationMetricNames.Count == 0)
{
-#pragma warning disable S103 // Lines should not be too long
throw new InvalidOperationException(
$"The '{nameof(evaluator.EvaluationMetricNames)}' property on '{evaluator.GetType().FullName}' returned an empty collection. An evaluator must advertise the names of the metrics that it supports.");
-#pragma warning restore S103
}
foreach (string metricName in evaluator.EvaluationMetricNames)
@@ -149,10 +147,8 @@ async ValueTask EvaluateAsync(IEvaluator e)
if (e.EvaluationMetricNames.Count == 0)
{
-#pragma warning disable S103 // Lines should not be too long
throw new InvalidOperationException(
$"The '{nameof(e.EvaluationMetricNames)}' property on '{e.GetType().FullName}' returned an empty collection. An evaluator must advertise the names of the metrics that it supports.");
-#pragma warning restore S103
}
foreach (string metricName in e.EvaluationMetricNames)
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationContext.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationContext.cs
index 203d86a84fa..05bdac6e68e 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationContext.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationContext.cs
@@ -42,20 +42,13 @@ namespace Microsoft.Extensions.AI.Evaluation;
/// contextual information that is modeled by the .
///
///
-#pragma warning disable S1694 // An abstract class should have both abstract and concrete methods
public abstract class EvaluationContext
-#pragma warning restore S1694
{
///
/// Gets or sets the name for this .
///
public string Name { get; set; }
-#pragma warning disable CA2227
- // CA2227: Collection properties should be read only.
- // We disable this warning because we want this property to be fully mutable for serialization purposes and for
- // general convenience.
-
///
/// Gets or sets a list of objects that include all the information present in this
/// .
@@ -97,7 +90,6 @@ public abstract class EvaluationContext
/// .
///
public IList Contents { get; set; }
-#pragma warning restore CA2227
///
/// Initializes a new instance of the class.
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationDiagnostic.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationDiagnostic.cs
index 67ec3b13ebb..64ec8e913b9 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationDiagnostic.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationDiagnostic.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric.cs
index 19d05c20bc4..112cd53d382 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
using System.Collections.Generic;
using System.Text.Json.Serialization;
@@ -43,11 +38,6 @@ public class EvaluationMetric(string name, string? reason = null)
///
public EvaluationMetricInterpretation? Interpretation { get; set; }
-#pragma warning disable CA2227
- // CA2227: Collection properties should be read only.
- // We disable this warning because we want this type to be fully mutable for serialization purposes and for general
- // convenience.
-
///
/// Gets or sets any s that were considered by the as part
/// of the evaluation that produced the current .
@@ -65,5 +55,4 @@ public class EvaluationMetric(string name, string? reason = null)
/// .
///
public IDictionary? Metadata { get; set; }
-#pragma warning restore CA2227
}
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetricInterpretation.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetricInterpretation.cs
index 5206324edb6..b54f92e57c9 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetricInterpretation.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetricInterpretation.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric{T}.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric{T}.cs
index d2745069bc5..73965d9527d 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric{T}.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationMetric{T}.cs
@@ -1,11 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#pragma warning disable S3604
-// S3604: Member initializer values should not be redundant.
-// We disable this warning because it is a false positive arising from the analyzer's lack of support for C#'s primary
-// constructor syntax.
-
namespace Microsoft.Extensions.AI.Evaluation;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationResult.cs b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationResult.cs
index 94ce86abfd9..a60ebd71e42 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationResult.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Evaluation/EvaluationResult.cs
@@ -16,17 +16,11 @@ namespace Microsoft.Extensions.AI.Evaluation;
///
public sealed class EvaluationResult
{
-#pragma warning disable CA2227
- // CA2227: Collection properties should be read only.
- // We disable this warning because we want this type to be fully mutable for serialization purposes and for general
- // convenience.
-
///
/// Gets or sets a collection of one or more s that represent the result of an
/// evaluation.
///
public IDictionary Metrics { get; set; }
-#pragma warning restore CA2227
///
/// Initializes a new instance of the class.
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/Microsoft.Extensions.AI.OpenAI.csproj b/src/Libraries/Microsoft.Extensions.AI.OpenAI/Microsoft.Extensions.AI.OpenAI.csproj
index ce5a5fd89c0..666db46bfc1 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/Microsoft.Extensions.AI.OpenAI.csproj
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/Microsoft.Extensions.AI.OpenAI.csproj
@@ -15,7 +15,7 @@
$(TargetFrameworks);netstandard2.0
- $(NoWarn);CA1063;CA1508;CA2227;SA1316;S1121;S3358;EA0002
+ $(NoWarn);CA1063
$(NoWarn);OPENAI001;OPENAI002;MEAI001
true
true
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantsChatClient.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantsChatClient.cs
index 424185db887..ea682a11beb 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantsChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantsChatClient.cs
@@ -12,17 +12,11 @@
using Microsoft.Shared.Diagnostics;
using OpenAI.Assistants;
-#pragma warning disable CA1031 // Do not catch general exception types
#pragma warning disable SA1005 // Single line comments should begin with single space
#pragma warning disable SA1204 // Static elements should appear before instance elements
-#pragma warning disable S103 // Lines should not be too long
#pragma warning disable S125 // Sections of code should not be commented out
-#pragma warning disable S907 // "goto" statement should not be used
-#pragma warning disable S1067 // Expressions should not be too complex
#pragma warning disable S1751 // Loops with at most one iteration should be refactored
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
-#pragma warning disable S4456 // Parameter validation in yielding methods should be wrapped
-#pragma warning disable S4457 // Parameter validation in "async"/"await" methods should be wrapped
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs
index 33f22dda420..1ce67c78a51 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs
@@ -18,12 +18,7 @@
using OpenAI.Chat;
#pragma warning disable CA1308 // Normalize strings to uppercase
-#pragma warning disable EA0011 // Consider removing unnecessary conditional access operator (?)
-#pragma warning disable S1067 // Expressions should not be too complex
-#pragma warning disable S2333 // Unnecessary partial
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
-#pragma warning disable SA1202 // Elements should be ordered by access
-#pragma warning disable SA1203 // Constants should appear before fields
#pragma warning disable SA1204 // Static elements should appear before instance elements
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs
index 19fa835851f..0ebda69246c 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs
@@ -16,7 +16,6 @@
using OpenAI.Images;
using OpenAI.Responses;
-#pragma warning disable S103 // Lines should not be too long
#pragma warning disable SA1515 // Single-line comment should be preceded by blank line
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIEmbeddingGenerator.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIEmbeddingGenerator.cs
index 9c3da231065..825937c9359 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIEmbeddingGenerator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIEmbeddingGenerator.cs
@@ -12,9 +12,7 @@
using Microsoft.Shared.Diagnostics;
using OpenAI.Embeddings;
-#pragma warning disable S1067 // Expressions should not be too complex
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
-#pragma warning disable EA0011 // Consider removing unnecessary conditional access operator (?)
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIImageGenerator.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIImageGenerator.cs
index 9281167d917..a51454d532c 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIImageGenerator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIImageGenerator.cs
@@ -7,7 +7,6 @@
using System.IO;
using System.Linq;
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
@@ -103,7 +102,6 @@ public async Task GenerateAsync(ImageGenerationRequest
}
///
-#pragma warning disable S1067 // Expressions should not be too complex
public object? GetService(Type serviceType, object? serviceKey = null) =>
serviceType is null ? throw new ArgumentNullException(nameof(serviceType)) :
serviceKey is not null ? null :
@@ -111,7 +109,6 @@ public async Task GenerateAsync(ImageGenerationRequest
serviceType == typeof(ImageClient) ? _imageClient :
serviceType.IsInstanceOfType(this) ? this :
null;
-#pragma warning restore S1067 // Expressions should not be too complex
///
void IDisposable.Dispose()
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
index 2720c7f761f..5da26a435ff 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
@@ -15,12 +15,8 @@
using Microsoft.Shared.Diagnostics;
using OpenAI.Responses;
-#pragma warning disable S907 // "goto" statement should not be used
-#pragma warning disable S1067 // Expressions should not be too complex
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
#pragma warning disable S3254 // Default parameter values should not be passed as arguments
-#pragma warning disable S3604 // Member initializer values should not be redundant
-#pragma warning disable SA1202 // Elements should be ordered by access
#pragma warning disable SA1204 // Static elements should appear before instance elements
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAISpeechToTextClient.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAISpeechToTextClient.cs
index 06051a54c26..fb0901eeb0d 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAISpeechToTextClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAISpeechToTextClient.cs
@@ -12,7 +12,6 @@
using OpenAI;
using OpenAI.Audio;
-#pragma warning disable S1067 // Expressions should not be too complex
#pragma warning disable S3011 // Reflection should not be used to increase accessibility of classes, methods, or fields
#pragma warning disable SA1204 // Static elements should appear before instance elements
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/AnonymousDelegatingChatClient.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/AnonymousDelegatingChatClient.cs
index db256e94916..9a3fb9d4ad6 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/AnonymousDelegatingChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/AnonymousDelegatingChatClient.cs
@@ -12,8 +12,6 @@
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable VSTHRD003 // Avoid awaiting foreign Tasks
-
namespace Microsoft.Extensions.AI;
/// Represents a delegating chat client that wraps an inner client with implementations provided by delegates.
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/CachingChatClient.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/CachingChatClient.cs
index 2923b0ad62d..cb5482ac213 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/CachingChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/CachingChatClient.cs
@@ -8,9 +8,6 @@
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S127 // "for" loop stop conditions should be invariant
-#pragma warning disable SA1202 // Elements should be ordered by access
-
namespace Microsoft.Extensions.AI;
///
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatResponse{T}.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatResponse{T}.cs
index 57c90307b67..a7a6c903834 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatResponse{T}.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatResponse{T}.cs
@@ -82,13 +82,11 @@ public bool TryGetResult([NotNullWhen(true)] out T? result)
result = GetResultCore(out var failureReason);
return failureReason is null;
}
-#pragma warning disable CA1031 // Do not catch general exception types
catch
{
result = default;
return false;
}
-#pragma warning restore CA1031 // Do not catch general exception types
}
private static T? DeserializeFirstTopLevelObject(string json, JsonTypeInfo typeInfo)
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs
index afaa12235ec..47984962598 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs
@@ -11,8 +11,6 @@
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S109 // Magic numbers should not be used
-#pragma warning disable SA1202 // Elements should be ordered by access
#pragma warning disable SA1502 // Element should not be on a single line
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
index 0137ac06c7f..4495d592adb 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
@@ -14,13 +14,7 @@
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable CA1508 // Avoid dead conditional code
#pragma warning disable CA2213 // Disposable fields should be disposed
-#pragma warning disable EA0002 // Use 'System.TimeProvider' to make the code easier to test
-#pragma warning disable SA1202 // 'protected' members should come before 'private' members
-#pragma warning disable S107 // Methods should not have too many parameters
-#pragma warning disable S907 // "goto" statement should not be used
-#pragma warning disable S1659 // Multiple variables should not be declared on the same line
#pragma warning disable S3353 // Unchanged local variables should be "const"
#pragma warning disable IDE0031 // Use null propagation, suppressed until repo updates to C# 14
#pragma warning disable IDE0032 // Use auto property, suppressed until repo updates to C# 14
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs
index 137392bf1ce..33c9306aa11 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs
@@ -15,7 +15,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S3358 // Ternary operators should not be nested
#pragma warning disable SA1111 // Closing parenthesis should be on line of last parameter
#pragma warning disable SA1113 // Comma should be on the same line as previous parameter
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryImageGenerator.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryImageGenerator.cs
index 28be6407d19..b6ef8ea04e0 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryImageGenerator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryImageGenerator.cs
@@ -7,13 +7,11 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Metrics;
using System.Drawing;
-using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable S3358 // Ternary operators should not be nested
#pragma warning disable SA1111 // Closing parenthesis should be on line of last parameter
#pragma warning disable SA1113 // Comma should be on the same line as previous parameter
diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatReduction/SummarizingChatReducer.cs b/src/Libraries/Microsoft.Extensions.AI/ChatReduction/SummarizingChatReducer.cs
index ac57e919277..b79d1d18197 100644
--- a/src/Libraries/Microsoft.Extensions.AI/ChatReduction/SummarizingChatReducer.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/ChatReduction/SummarizingChatReducer.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
diff --git a/src/Libraries/Microsoft.Extensions.AI/Embeddings/ConfigureOptionsEmbeddingGeneratorBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.AI/Embeddings/ConfigureOptionsEmbeddingGeneratorBuilderExtensions.cs
index 73867e4b2f7..d2657bfdd1f 100644
--- a/src/Libraries/Microsoft.Extensions.AI/Embeddings/ConfigureOptionsEmbeddingGeneratorBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/Embeddings/ConfigureOptionsEmbeddingGeneratorBuilderExtensions.cs
@@ -4,8 +4,6 @@
using System;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable SA1629 // Documentation text should end with a period
-
namespace Microsoft.Extensions.AI;
/// Provides extensions for configuring instances.
diff --git a/src/Libraries/Microsoft.Extensions.AI/Image/ConfigureOptionsImageGeneratorBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.AI/Image/ConfigureOptionsImageGeneratorBuilderExtensions.cs
index 337c80951ef..52c953fba77 100644
--- a/src/Libraries/Microsoft.Extensions.AI/Image/ConfigureOptionsImageGeneratorBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/Image/ConfigureOptionsImageGeneratorBuilderExtensions.cs
@@ -5,8 +5,6 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.Diagnostics;
-#pragma warning disable SA1629 // Documentation text should end with a period
-
namespace Microsoft.Extensions.AI;
/// Provides extensions for configuring instances.
diff --git a/src/Libraries/Microsoft.Extensions.AI/Image/LoggingImageGenerator.cs b/src/Libraries/Microsoft.Extensions.AI/Image/LoggingImageGenerator.cs
index 9ca0b8d06d2..f74701d766e 100644
--- a/src/Libraries/Microsoft.Extensions.AI/Image/LoggingImageGenerator.cs
+++ b/src/Libraries/Microsoft.Extensions.AI/Image/LoggingImageGenerator.cs
@@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Shared.Diagnostics;
-using static Microsoft.Extensions.AI.OpenTelemetryConsts.GenAI;
namespace Microsoft.Extensions.AI;
diff --git a/src/Libraries/Microsoft.Extensions.AI/Microsoft.Extensions.AI.csproj b/src/Libraries/Microsoft.Extensions.AI/Microsoft.Extensions.AI.csproj
index 0d77680cbc4..36e6bb00562 100644
--- a/src/Libraries/Microsoft.Extensions.AI/Microsoft.Extensions.AI.csproj
+++ b/src/Libraries/Microsoft.Extensions.AI/Microsoft.Extensions.AI.csproj
@@ -1,4 +1,4 @@
-
+
Microsoft.Extensions.AI
@@ -14,7 +14,7 @@
$(TargetFrameworks);netstandard2.0
- $(NoWarn);CA2227;CA1034;SA1316;S1067;S1121;S1994;S3253;MEAI001
+ $(NoWarn);MEAI001