|
17 | 17 | using System.Diagnostics.CodeAnalysis;
|
18 | 18 | using System.Linq;
|
19 | 19 | using System.Reflection;
|
| 20 | +using System.Runtime.CompilerServices; |
20 | 21 | using System.Xml.Linq;
|
21 | 22 | using Amazon.Runtime;
|
22 | 23 | using Amazon.Runtime.CredentialManagement;
|
23 | 24 | using Amazon.Runtime.Credentials.Internal;
|
| 25 | +using Amazon.Util; |
24 | 26 | using Microsoft.Extensions.Configuration;
|
25 | 27 | using Microsoft.Extensions.DependencyInjection;
|
26 | 28 | using Microsoft.Extensions.Logging;
|
@@ -295,10 +297,6 @@ private ClientConfig CreateConfig(AWSOptions options)
|
295 | 297 | {
|
296 | 298 | config.FastFailRequests = defaultConfig.FastFailRequests.Value;
|
297 | 299 | }
|
298 |
| - if (defaultConfig.HttpClientCacheSize.HasValue) |
299 |
| - { |
300 |
| - config.HttpClientCacheSize = defaultConfig.HttpClientCacheSize.Value; |
301 |
| - } |
302 | 300 | if (defaultConfig.IgnoreConfiguredEndpointUrls.HasValue)
|
303 | 301 | {
|
304 | 302 | config.IgnoreConfiguredEndpointUrls = defaultConfig.IgnoreConfiguredEndpointUrls.Value;
|
@@ -367,9 +365,28 @@ private ClientConfig CreateConfig(AWSOptions options)
|
367 | 365 | ProcessServiceSpecificSettings(config, defaultConfig.ServiceSpecificSettings);
|
368 | 366 | }
|
369 | 367 |
|
| 368 | + // It is possible that this library might be used in .NET Framework application. In that |
| 369 | + // case the SDK used at runtime will be the .NET Framework variant. To avoid getting |
| 370 | + // MissingMethodException exceptions for config properties that don't exist in |
| 371 | + // .NET Framework variant put the set calls in a separate method only called |
| 372 | + // if the SDK is not the .NET Framework variant. |
| 373 | + if (!AWSSDKUtils.IsNETFramework()) |
| 374 | + { |
| 375 | + SetNETStandardAndAboveSettings(defaultConfig, config); |
| 376 | + } |
| 377 | + |
370 | 378 | return config;
|
371 | 379 | }
|
372 | 380 |
|
| 381 | + [MethodImpl(MethodImplOptions.NoInlining)] |
| 382 | + private void SetNETStandardAndAboveSettings(DefaultClientConfig defaultConfig, ClientConfig config) |
| 383 | + { |
| 384 | + if (defaultConfig.HttpClientCacheSize.HasValue) |
| 385 | + { |
| 386 | + config.HttpClientCacheSize = defaultConfig.HttpClientCacheSize.Value; |
| 387 | + } |
| 388 | + } |
| 389 | + |
373 | 390 | #if NET8_0_OR_GREATER
|
374 | 391 | [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075",
|
375 | 392 | Justification = "The parent calling method uses the DynamicDependencyAttribute on the service client to ensure the public properties are not trimmed.")]
|
|
0 commit comments