-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added overloads to GetAWSOptions that allow creating service specific client configs #2571
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,39 +219,37 @@ private static ClientConfig CreateConfig(Type serviceInterfaceType, AWSOptions o | |
} | ||
|
||
var defaultConfig = options.DefaultClientConfig; | ||
if (options.IsDefaultClientConfigSet) | ||
{ | ||
var emptyArray = new object[0]; | ||
var singleArray = new object[1]; | ||
var emptyArray = new object[0]; | ||
var singleArray = new object[1]; | ||
|
||
var clientConfigTypeInfo = typeof(ClientConfig).GetTypeInfo(); | ||
foreach (var property in clientConfigTypeInfo.DeclaredProperties) | ||
var clientConfigTypeInfo = options.DefaultClientConfig.GetType(); | ||
var properties = clientConfigTypeInfo.GetProperties(BindingFlags.Public | BindingFlags.Instance); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the uses of This is also probably good to do because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since options is gauranteed to have a value I agree that it's fine to use |
||
foreach (var property in properties) | ||
{ | ||
if (property.GetMethod != null && property.SetMethod != null) | ||
{ | ||
if (property.GetMethod != null && property.SetMethod != null) | ||
{ | ||
// Skip RegionEndpoint because it is set below and calling the get method on the | ||
// property triggers the default region fallback mechanism. | ||
if (string.Equals(property.Name, "RegionEndpoint", StringComparison.Ordinal)) | ||
continue; | ||
// Skip RegionEndpoint because it is set below and calling the get method on the | ||
// property triggers the default region fallback mechanism. | ||
if (string.Equals(property.Name, "RegionEndpoint", StringComparison.Ordinal)) | ||
continue; | ||
|
||
// DefaultConfigurationMode is skipped from the DefaultClientConfig because it is expected to be set | ||
// at the top level of AWSOptions which is done before this loop. | ||
if (string.Equals(property.Name, "DefaultConfigurationMode", StringComparison.Ordinal)) | ||
continue; | ||
// DefaultConfigurationMode is skipped from the DefaultClientConfig because it is expected to be set | ||
// at the top level of AWSOptions which is done before this loop. | ||
if (string.Equals(property.Name, "DefaultConfigurationMode", StringComparison.Ordinal)) | ||
continue; | ||
|
||
// Skip setting RetryMode if it is set to legacy but the DefaultConfigurationMode is not legacy. | ||
// This will allow the retry mode to be configured from the DefaultConfiguration. | ||
// This is a workaround to handle the inability to tell if RetryMode was explicitly set. | ||
if (string.Equals(property.Name, "RetryMode", StringComparison.Ordinal) && | ||
defaultConfig.RetryMode == RequestRetryMode.Legacy && | ||
config.DefaultConfigurationMode != DefaultConfigurationMode.Legacy) | ||
continue; | ||
// Skip setting RetryMode if it is set to legacy but the DefaultConfigurationMode is not legacy. | ||
// This will allow the retry mode to be configured from the DefaultConfiguration. | ||
// This is a workaround to handle the inability to tell if RetryMode was explicitly set. | ||
if (string.Equals(property.Name, "RetryMode", StringComparison.Ordinal) && | ||
defaultConfig.RetryMode == RequestRetryMode.Legacy && | ||
config.DefaultConfigurationMode != DefaultConfigurationMode.Legacy) | ||
continue; | ||
|
||
singleArray[0] = property.GetMethod.Invoke(defaultConfig, emptyArray); | ||
if (singleArray[0] != null) | ||
{ | ||
property.SetMethod.Invoke(config, singleArray); | ||
} | ||
singleArray[0] = property.GetMethod.Invoke(defaultConfig, emptyArray); | ||
if (singleArray[0] != null) | ||
{ | ||
property.SetMethod.Invoke(config, singleArray); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the one use of the internal
IsDefaultClientConfigSet
which checks to see if the backing field ofDefaultClientConfig
is null. If you readDefaultClientConfig
like is done above it sets the value so this is always true.I went ahead and deleted the property in order to not have this gotcha sitting around.