Skip to content

Commit dfee413

Browse files
committed
Address new issues after multi-targeting
1 parent 041a2ba commit dfee413

9 files changed

Lines changed: 56 additions & 5 deletions

File tree

shared-package.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
3434
</PropertyGroup>
3535

36+
<PropertyGroup>
37+
<!--
38+
Temporary workaround for CA1873: Evaluation of this argument may be expensive and unnecessary if logging is disabled.
39+
Should be revisited as part of https://github.com/SteeltoeOSS/Steeltoe/issues/969.
40+
-->
41+
<NoWarn>$(NoWarn);CA1873</NoWarn>
42+
</PropertyGroup>
43+
3644
<PropertyGroup Condition="'$(CI)' != ''">
3745
<!--
3846
While deterministic builds are enabled by default in .NET SDK projects, there is an extra property, ContinuousIntegrationBuild,

src/Common/src/Certificates/ConfigureCertificateOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ public void Configure(string? name, CertificateOptions options)
4242

4343
string? privateKeyFilePath = _configuration.GetValue<string>(GetConfigurationKey(name, "PrivateKeyFilePath"));
4444

45+
#pragma warning disable SYSLIB0057 // Type or member is obsolete
4546
options.Certificate = privateKeyFilePath != null && File.Exists(privateKeyFilePath)
4647
? X509Certificate2.CreateFromPemFile(certificateFilePath, privateKeyFilePath)
4748
: new X509Certificate2(certificateFilePath);
4849

4950
X509Certificate2[] certificateChain = CertificateRegex.Matches(File.ReadAllText(certificateFilePath))
5051
.Select(x => new X509Certificate2(Encoding.ASCII.GetBytes(x.Value))).ToArray();
52+
#pragma warning restore SYSLIB0057 // Type or member is obsolete
5153

5254
foreach (X509Certificate2 issuer in certificateChain.Skip(1))
5355
{

src/Common/src/Certificates/LocalCertificateWriter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public void Write(Guid orgId, Guid spaceId)
6363
}
6464
else
6565
{
66+
#pragma warning disable SYSLIB0057 // Type or member is obsolete
6667
caCertificate = new X509Certificate2(RootCaPfxPath);
68+
#pragma warning restore SYSLIB0057 // Type or member is obsolete
6769
}
6870

6971
// Create the intermediate certificate if it doesn't already exist (can be shared by multiple applications)
@@ -76,7 +78,9 @@ public void Write(Guid orgId, Guid spaceId)
7678
}
7779
else
7880
{
81+
#pragma warning disable SYSLIB0057 // Type or member is obsolete
7982
intermediateCertificate = new X509Certificate2(IntermediatePfxPath);
83+
#pragma warning restore SYSLIB0057 // Type or member is obsolete
8084
}
8185

8286
var subjectAlternativeNameBuilder = new SubjectAlternativeNameBuilder();

src/Common/src/Logging/BootstrapLoggerFactory.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
using Microsoft.Extensions.Configuration;
66
using Microsoft.Extensions.Logging;
7+
using LockPrimitive =
8+
#if NET10_0_OR_GREATER
9+
System.Threading.Lock
10+
#else
11+
object
12+
#endif
13+
;
714

815
namespace Steeltoe.Common.Logging;
916

@@ -30,7 +37,7 @@ public sealed class BootstrapLoggerFactory : ILoggerFactory
3037
loggingBuilder.AddConfiguration(configuration);
3138
};
3239

33-
private readonly object _lock = new();
40+
private readonly LockPrimitive _lock = new();
3441
private readonly Dictionary<string, UpgradableLogger> _loggersByCategoryName = [];
3542
private ILoggerFactory _innerFactory;
3643

src/Connectors/src/Connectors/Connector.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
using Microsoft.Extensions.DependencyInjection;
66
using Microsoft.Extensions.Options;
7+
using LockPrimitive =
8+
#if NET10_0_OR_GREATER
9+
System.Threading.Lock
10+
#else
11+
object
12+
#endif
13+
;
714

815
namespace Steeltoe.Connectors;
916

@@ -25,7 +32,7 @@ public sealed class Connector<TOptions, TConnection> : IDisposable
2532
private readonly bool _useSingletonConnection;
2633
private readonly IOptionsMonitor<TOptions> _optionsMonitor;
2734

28-
private readonly object _singletonLock = new();
35+
private readonly LockPrimitive _singletonLock = new();
2936
private ConnectionWithOptionsSnapshot? _singletonSnapshot;
3037
private bool _singletonIsDisposed;
3138

src/Discovery/src/Eureka/EurekaApplicationInfoManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
using Microsoft.Extensions.Options;
77
using Steeltoe.Discovery.Eureka.AppInfo;
88
using Steeltoe.Discovery.Eureka.Configuration;
9+
using LockPrimitive =
10+
#if NET10_0_OR_GREATER
11+
System.Threading.Lock
12+
#else
13+
object
14+
#endif
15+
;
916

1017
namespace Steeltoe.Discovery.Eureka;
1118

@@ -19,7 +26,7 @@ public sealed class EurekaApplicationInfoManager : IDisposable
1926
private readonly TimeProvider _timeProvider;
2027
private readonly IDisposable? _instanceOptionsChangeToken;
2128
private readonly ILogger<EurekaApplicationInfoManager> _logger;
22-
private readonly object _instanceWriteLock = new();
29+
private readonly LockPrimitive _instanceWriteLock = new();
2330

2431
// Readers must never be blocked, as it may delay the periodic heartbeat.
2532
// Updates from user code must be synchronized with configuration changes.

src/Discovery/src/Eureka/EurekaServiceUriStateManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
using Microsoft.Extensions.Options;
77
using Steeltoe.Discovery.Eureka.Configuration;
88
using Steeltoe.Discovery.Eureka.Transport;
9+
using LockPrimitive =
10+
#if NET10_0_OR_GREATER
11+
System.Threading.Lock
12+
#else
13+
object
14+
#endif
15+
;
916

1017
namespace Steeltoe.Discovery.Eureka;
1118

@@ -17,7 +24,7 @@ public sealed class EurekaServiceUriStateManager
1724
private readonly IOptionsMonitor<EurekaClientOptions> _optionsMonitor;
1825
private readonly ILogger<EurekaServiceUriStateManager> _logger;
1926

20-
private readonly object _lockObject = new();
27+
private readonly LockPrimitive _lockObject = new();
2128
private readonly HashSet<Uri> _failedServiceUris = [];
2229
private Uri? _lastWorkingServiceUri;
2330

src/Logging/src/DynamicSerilog/DynamicSerilogLoggerProvider.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
using Serilog.Core;
88
using Serilog.Events;
99
using Serilog.Extensions.Logging;
10+
using LockPrimitive =
11+
#if NET10_0_OR_GREATER
12+
System.Threading.Lock
13+
#else
14+
object
15+
#endif
16+
;
1017

1118
namespace Steeltoe.Logging.DynamicSerilog;
1219

@@ -15,7 +22,7 @@ namespace Steeltoe.Logging.DynamicSerilog;
1522
/// </summary>
1623
public sealed class DynamicSerilogLoggerProvider : DynamicLoggerProvider
1724
{
18-
private static readonly object LoggerLock = new();
25+
private static readonly LockPrimitive LoggerLock = new();
1926
private static Logger? _serilogLogger;
2027
private readonly IDisposable? _optionsChangeListener;
2128

src/Security/src/Authorization.Certificate/PostConfigureCertificateAuthenticationOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ public void PostConfigure(string? name, CertificateAuthenticationOptions options
3939

4040
if (!string.IsNullOrEmpty(systemCertPath))
4141
{
42+
#pragma warning disable SYSLIB0057 // Type or member is obsolete
4243
X509Certificate2[] systemCertificates =
4344
Directory.GetFiles(systemCertPath).Select(certificateFilename => new X509Certificate2(certificateFilename)).ToArray();
45+
#pragma warning restore SYSLIB0057 // Type or member is obsolete
4446

4547
options.CustomTrustStore.AddRange(systemCertificates);
4648
}

0 commit comments

Comments
 (0)