diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig
index a4def7dae8b198..a4f79c6da3cfc5 100644
--- a/eng/CodeAnalysis.src.globalconfig
+++ b/eng/CodeAnalysis.src.globalconfig
@@ -480,7 +480,7 @@ dotnet_diagnostic.CA1860.severity = warning
# CA1861: Avoid constant arrays as arguments
dotnet_diagnostic.CA1861.severity = warning
-# CA1862: Prefer using 'StringComparer'/'StringComparison' to perform case-insensitive string comparisons
+# CA1862: Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
dotnet_diagnostic.CA1862.severity = suggestion
# CA1863: Use 'CompositeFormat'
@@ -513,6 +513,15 @@ dotnet_diagnostic.CA1871.severity = warning
# CA1872: Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString'
dotnet_diagnostic.CA1872.severity = warning
+# CA1873: Avoid potentially expensive logging
+dotnet_diagnostic.CA1873.severity = warning
+
+# CA1874: Use 'Regex.IsMatch'
+dotnet_diagnostic.CA1874.severity = warning
+
+# CA1875: Use 'Regex.Count'
+dotnet_diagnostic.CA1875.severity = warning
+
# CA2000: Dispose objects before losing scope
dotnet_diagnostic.CA2000.severity = none
@@ -564,7 +573,13 @@ dotnet_diagnostic.CA2021.severity = warning
# CA2022: Avoid inexact read with 'Stream.Read'
dotnet_diagnostic.CA2022.severity = warning
-# CA2025: Ensure tasks using 'IDisposable' instances complete before the instances are disposed
+# CA2023: Invalid braces in message template
+dotnet_diagnostic.CA2023.severity = warning
+
+# CA2024: Do not use 'StreamReader.EndOfStream' in async methods
+dotnet_diagnostic.CA2024.severity = warning
+
+# CA2025: Do not pass 'IDisposable' instances into unawaited tasks
dotnet_diagnostic.CA2025.severity = warning
# CA2100: Review SQL queries for security vulnerabilities
diff --git a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs
index 07b78f196d2e34..9290e23086dedf 100644
--- a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs
+++ b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs
@@ -241,7 +241,7 @@ private void MatchType(TypeDesc type, Regex regex, XPathNavigator nav)
{
StringBuilder sb = new StringBuilder();
CecilTypeNameFormatter.Instance.AppendName(sb, type);
- if (regex.Match(sb.ToString()).Success)
+ if (regex.IsMatch(sb.ToString()))
ProcessType(type, nav);
}
diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs
index 6ca04aa0ffa6e3..562b108fcd6f26 100644
--- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs
+++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs
@@ -92,8 +92,11 @@ public Task WaitForStartAsync(CancellationToken cancellationToken)
private void OnApplicationStarted()
{
- Logger.LogInformation("Application started. Hosting environment: {EnvironmentName}; Content root path: {ContentRoot}",
- Environment.EnvironmentName, Environment.ContentRootPath);
+ if (Logger.IsEnabled(LogLevel.Information))
+ {
+ Logger.LogInformation("Application started. Hosting environment: {EnvironmentName}; Content root path: {ContentRoot}",
+ Environment.EnvironmentName, Environment.ContentRootPath);
+ }
SystemdNotifier.Notify(ServiceState.Ready);
}
diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs
index a1b58c01f630ce..63073a6694e924 100644
--- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs
+++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs
@@ -77,8 +77,11 @@ public Task WaitForStartAsync(CancellationToken cancellationToken)
cancellationToken.Register(() => _delayStart.TrySetCanceled());
ApplicationLifetime.ApplicationStarted.Register(() =>
{
- Logger.LogInformation("Application started. Hosting environment: {EnvName}; Content root path: {ContentRoot}",
+ if (Logger.IsEnabled(LogLevel.Information))
+ {
+ Logger.LogInformation("Application started. Hosting environment: {EnvName}; Content root path: {ContentRoot}",
Environment.EnvironmentName, Environment.ContentRootPath);
+ }
});
ApplicationLifetime.ApplicationStopping.Register(() =>
{
diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs
index b197587d47aa46..b19ae087d23db0 100644
--- a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs
+++ b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs
@@ -99,9 +99,12 @@ public Task WaitForStartAsync(CancellationToken cancellationToken)
private void OnApplicationStarted()
{
- Logger.LogInformation("Application started. Press Ctrl+C to shut down.");
- Logger.LogInformation("Hosting environment: {EnvName}", Environment.EnvironmentName);
- Logger.LogInformation("Content root path: {ContentRoot}", Environment.ContentRootPath);
+ if (Logger.IsEnabled(LogLevel.Information))
+ {
+ Logger.LogInformation("Application started. Press Ctrl+C to shut down.");
+ Logger.LogInformation("Hosting environment: {EnvName}", Environment.EnvironmentName);
+ Logger.LogInformation("Content root path: {ContentRoot}", Environment.ContentRootPath);
+ }
}
private void OnApplicationStopping()
diff --git a/src/mono/browser/debugger/BrowserDebugHost/BrowserDebugHost.csproj b/src/mono/browser/debugger/BrowserDebugHost/BrowserDebugHost.csproj
index 4e9beb28990fd9..49c81579953224 100644
--- a/src/mono/browser/debugger/BrowserDebugHost/BrowserDebugHost.csproj
+++ b/src/mono/browser/debugger/BrowserDebugHost/BrowserDebugHost.csproj
@@ -3,7 +3,7 @@
$(AspNetCoreAppCurrent)
true
- $(NoWarn),CA2007
+ $(NoWarn),CA2007,CA1873
false
Major
diff --git a/src/mono/browser/debugger/BrowserDebugProxy/BrowserDebugProxy.csproj b/src/mono/browser/debugger/BrowserDebugProxy/BrowserDebugProxy.csproj
index b13a22f29fa153..d27fe41d00f58c 100644
--- a/src/mono/browser/debugger/BrowserDebugProxy/BrowserDebugProxy.csproj
+++ b/src/mono/browser/debugger/BrowserDebugProxy/BrowserDebugProxy.csproj
@@ -2,7 +2,7 @@
$(AspNetCoreAppCurrent)
- $(NoWarn),CA2007
+ $(NoWarn),CA2007,CA1873
true
true
diff --git a/src/mono/wasm/host/WasmAppHost.csproj b/src/mono/wasm/host/WasmAppHost.csproj
index b6c8fa42fc25de..1f580c86b357e0 100644
--- a/src/mono/wasm/host/WasmAppHost.csproj
+++ b/src/mono/wasm/host/WasmAppHost.csproj
@@ -3,7 +3,7 @@
$(AspNetCoreAppCurrent)
true
- $(NoWarn);CA2007
+ $(NoWarn);CA2007;CA1873
enable
false
LatestMajor
diff --git a/src/mono/wasm/symbolicator/WasmSymbolicator.csproj b/src/mono/wasm/symbolicator/WasmSymbolicator.csproj
index dfda68aee743cf..45a2b5fefbc76b 100644
--- a/src/mono/wasm/symbolicator/WasmSymbolicator.csproj
+++ b/src/mono/wasm/symbolicator/WasmSymbolicator.csproj
@@ -9,6 +9,7 @@
Exe
enable
enable
+ $(NoWarn);CA1873
diff --git a/src/tools/illink/src/linker/Linker.Steps/ProcessLinkerXmlBase.cs b/src/tools/illink/src/linker/Linker.Steps/ProcessLinkerXmlBase.cs
index c5e19286bb0e1d..3d7bb2b2f2d6d9 100644
--- a/src/tools/illink/src/linker/Linker.Steps/ProcessLinkerXmlBase.cs
+++ b/src/tools/illink/src/linker/Linker.Steps/ProcessLinkerXmlBase.cs
@@ -215,7 +215,7 @@ protected virtual void ProcessTypes(AssemblyDefinition assembly, XPathNavigator
void MatchType(TypeDefinition type, Regex regex, XPathNavigator nav)
{
- if (regex.Match(type.FullName).Success)
+ if (regex.IsMatch(type.FullName))
ProcessType(type, nav);
if (!type.HasNestedTypes)
@@ -238,7 +238,7 @@ protected virtual bool ProcessTypePattern(string fullname, AssemblyDefinition as
{
foreach (var exported in assembly.MainModule.ExportedTypes)
{
- if (regex.Match(exported.FullName).Success)
+ if (regex.IsMatch(exported.FullName))
{
var type = ProcessExportedType(exported, assembly, nav);
if (type != null)