diff --git a/.editorconfig b/.editorconfig index 9f69e2158..12bc97524 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,66 +1,207 @@ -# To learn more about .editorconfig see https://aka.ms/editorconfigdocs -############################### -# Core EditorConfig Options # -############################### -root = true +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true -# All files -[*] -indent_style = space +# C# files +[*.cs] -# Code files -[*.cs] +#### Core EditorConfig Options #### + +# Indentation and spacing indent_size = 4 +indent_style = space tab_width = 4 -trim_trailing_whitespace = true -############################### -# .NET Coding Conventions # -############################### -[*.cs] -# Organize usings +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings dotnet_separate_import_directive_groups = false dotnet_sort_system_directives_first = true +file_header_template = unset -# this. preferences -dotnet_style_qualification_for_field = true:error -dotnet_style_qualification_for_property = true:error -dotnet_style_qualification_for_method = true:error +# this. and Me. preferences dotnet_style_qualification_for_event = true:error +dotnet_style_qualification_for_field = true:error +dotnet_style_qualification_for_method = true:error +dotnet_style_qualification_for_property = true:error -# New line preferences -csharp_new_line_before_open_brace = all +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent -# Indentation preferences -csharp_indent_case_contents = true -csharp_indent_switch_labels = true -csharp_indent_labels = flush_left +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:error +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:error +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:error +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:error -# Space preferences -csharp_space_after_keywords_in_control_flow_statements = true +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:error -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:error -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:error -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:error +# Expression-level preferences +dotnet_style_coalesce_expression = true:error +dotnet_style_collection_initializer = true:error +dotnet_style_explicit_tuple_names = true:error +dotnet_style_null_propagation = true:error +dotnet_style_object_initializer = true:error +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:error +dotnet_style_prefer_compound_assignment = true:error +dotnet_style_prefer_conditional_expression_over_assignment = true:error +dotnet_style_prefer_conditional_expression_over_return = false:silent +dotnet_style_prefer_inferred_anonymous_type_member_names = true:error +dotnet_style_prefer_inferred_tuple_names = true:error +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error +dotnet_style_prefer_simplified_boolean_expressions = true:error +dotnet_style_prefer_simplified_interpolation = true:error -# Expression-level preferences -dotnet_style_prefer_auto_properties = true:error -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error +# Field preferences +dotnet_style_readonly_field = true:error -# CSharp code style settings: +# Parameter preferences +dotnet_code_quality_unused_parameters = all:error + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false:error csharp_style_var_for_built_in_types = false:error csharp_style_var_when_type_is_apparent = false:error -csharp_style_var_elsewhere = false:error -# Patern matching -csharp_style_pattern_matching_over_is_with_cast_check = true:error +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:error +csharp_style_expression_bodied_constructors = false:error +csharp_style_expression_bodied_indexers = true:error +csharp_style_expression_bodied_lambdas = true:error +csharp_style_expression_bodied_local_functions = false:error +csharp_style_expression_bodied_methods = false:error +csharp_style_expression_bodied_operators = false:error +csharp_style_expression_bodied_properties = true:error + +# Pattern matching preferences csharp_style_pattern_matching_over_as_with_null_check = true:error +csharp_style_pattern_matching_over_is_with_cast_check = true:error +csharp_style_prefer_switch_expression = true:error + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:error + +# Modifier preferences +csharp_prefer_static_local_function = true:error +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:silent + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:error +csharp_style_deconstructed_variable_declaration = true:error +csharp_style_inlined_variable_declaration = true:error +csharp_style_pattern_local_over_anonymous_function = true:error +csharp_style_prefer_index_operator = true:error +csharp_style_prefer_range_operator = true:error +csharp_style_throw_expression = true:error +csharp_style_unused_value_assignment_preference = discard_variable:error +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# 'using' directive preferences +csharp_using_directive_placement = inside_namespace :error + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = error +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = error +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case ## Naming Conventions # Async methods should have [Async] suffix -[*.cs] dotnet_naming_rule.async_method_must_end_with_async.symbols = async_methods dotnet_naming_symbols.async_methods.applicable_kinds = method dotnet_naming_symbols.async_methods.applicable_accessibilities = * diff --git a/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapMetadata.cs b/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapMetadata.cs index b97c45af3..3f6df5d14 100644 --- a/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapMetadata.cs +++ b/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapMetadata.cs @@ -11,7 +11,7 @@ namespace Microsoft.Azure.Cosmos.Encryption /// public sealed class AzureKeyVaultKeyWrapMetadata : EncryptionKeyWrapMetadata { - internal static string TypeConstant = "akv"; + internal const string TypeConstant = "akv"; /// /// Creates a new instance of metadata that the Azure Key Vault can use to wrap and unwrap keys. diff --git a/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapProvider.cs b/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapProvider.cs index be02cec48..efaf407ec 100644 --- a/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapProvider.cs +++ b/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/AzureKeyVaultKeyWrapProvider.cs @@ -80,7 +80,7 @@ namespace Microsoft.Azure.Cosmos.Encryption if (!KeyVaultKeyUriProperties.TryParse(new Uri(metadata.Value), out KeyVaultKeyUriProperties keyVaultUriProperties)) { - throw new ArgumentException("KeyVault Key Uri {0} is invalid.",metadata.Value); + throw new ArgumentException("KeyVault Key Uri {0} is invalid.", metadata.Value); } if (!await this.keyVaultAccessClient.ValidatePurgeProtectionAndSoftDeleteSettingsAsync(keyVaultUriProperties, cancellationToken)) diff --git a/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/KeyVaultAccessException.cs b/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/KeyVaultAccessException.cs index a5e89d4e2..5e0db9c9a 100644 --- a/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/KeyVaultAccessException.cs +++ b/Microsoft.Azure.Cosmos.Encryption/src/KeyVault/KeyVaultAccessException.cs @@ -8,7 +8,7 @@ namespace Microsoft.Azure.Cosmos.Encryption internal class KeyVaultAccessException : RequestFailedException { - public KeyVaultAccessException(int statusCode, string keyVaultErrorCode, string? errorMessage, Exception? innerException) + public KeyVaultAccessException(int statusCode, string keyVaultErrorCode, string errorMessage, Exception innerException) : base(statusCode, keyVaultErrorCode, errorMessage, innerException) { } diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs index 24edc147d..a7a8ea247 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs @@ -56,27 +56,12 @@ namespace Microsoft.Azure.Cosmos throw new ArgumentOutOfRangeException(nameof(maxBatchByteSize)); } - if (executor == null) - { - throw new ArgumentNullException(nameof(executor)); - } - - if (retrier == null) - { - throw new ArgumentNullException(nameof(retrier)); - } - - if (serializerCore == null) - { - throw new ArgumentNullException(nameof(serializerCore)); - } - this.batchOperations = new List(maxBatchOperationCount); - this.executor = executor; - this.retrier = retrier; + this.executor = executor ?? throw new ArgumentNullException(nameof(executor)); + this.retrier = retrier ?? throw new ArgumentNullException(nameof(retrier)); this.maxBatchByteSize = maxBatchByteSize; this.maxBatchOperationCount = maxBatchOperationCount; - this.serializerCore = serializerCore; + this.serializerCore = serializerCore ?? throw new ArgumentNullException(nameof(serializerCore)); } public virtual bool TryAdd(ItemBatchOperation operation) @@ -122,7 +107,7 @@ namespace Microsoft.Azure.Cosmos public virtual async Task DispatchAsync( BatchPartitionMetric partitionMetric, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { this.interlockIncrementCheck.EnterLockCheck(); @@ -183,7 +168,7 @@ namespace Microsoft.Azure.Cosmos { response.DiagnosticsContext = batchResponse.DiagnosticsContext; } - + if (!response.IsSuccessStatusCode) { Documents.ShouldRetryResult shouldRetry = await itemBatchOperation.Context.ShouldRetryAsync(response, cancellationToken); diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutor.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutor.cs index 57bcf4b4f..20f70f92a 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutor.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutor.cs @@ -27,7 +27,7 @@ namespace Microsoft.Azure.Cosmos { private const int DefaultDispatchTimerInSeconds = 1; private const int TimerWheelBucketCount = 20; - private readonly static TimeSpan TimerWheelResolution = TimeSpan.FromMilliseconds(50); + private static readonly TimeSpan TimerWheelResolution = TimeSpan.FromMilliseconds(50); private readonly ContainerInternal cosmosContainer; private readonly CosmosClientContext cosmosClientContext; @@ -78,7 +78,7 @@ namespace Microsoft.Azure.Cosmos public virtual async Task AddAsync( ItemBatchOperation operation, ItemRequestOptions itemRequestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (operation == null) { @@ -113,7 +113,7 @@ namespace Microsoft.Azure.Cosmos internal virtual async Task ValidateOperationAsync( ItemBatchOperation operation, ItemRequestOptions itemRequestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (itemRequestOptions != null) { diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutorCache.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutorCache.cs index a16683b40..6312a542e 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutorCache.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncContainerExecutorCache.cs @@ -16,7 +16,7 @@ namespace Microsoft.Azure.Cosmos { // Keeping same performance tuned value of Bulk V2. internal const int DefaultMaxBulkRequestBodySizeInBytes = 220201; - private ConcurrentDictionary executorsPerContainer = new ConcurrentDictionary(); + private readonly ConcurrentDictionary executorsPerContainer = new ConcurrentDictionary(); public BatchAsyncContainerExecutor GetExecutorForContainer( ContainerInternal container, diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs index 991257d9d..97d102087 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs @@ -34,6 +34,9 @@ namespace Microsoft.Azure.Cosmos private readonly int congestionDecreaseFactor = 5; private readonly int maxDegreeOfConcurrency; private readonly TimerWheel timerWheel; + private readonly SemaphoreSlim limiter; + private readonly BatchPartitionMetric oldPartitionMetric; + private readonly BatchPartitionMetric partitionMetric; private volatile BatchAsyncBatcher currentBatcher; private TimerWheelTimer currentTimer; @@ -41,12 +44,9 @@ namespace Microsoft.Azure.Cosmos private TimerWheelTimer congestionControlTimer; private Task congestionControlTask; - private SemaphoreSlim limiter; private int congestionDegreeOfConcurrency = 1; private long congestionWaitTimeInMilliseconds = 1000; - private BatchPartitionMetric oldPartitionMetric; - private BatchPartitionMetric partitionMetric; public BatchAsyncStreamer( int maxBatchOperationCount, diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchCore.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchCore.cs index 70dffd87f..6817635fa 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/BatchCore.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/BatchCore.cs @@ -201,7 +201,7 @@ namespace Microsoft.Azure.Cosmos } public override Task ExecuteAsync( - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ExecuteAsync( requestOptions: null, @@ -216,7 +216,7 @@ namespace Microsoft.Azure.Cosmos /// An awaitable which contains the completion status and results of each operation. public override Task ExecuteAsync( TransactionalBatchRequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.container.ClientContext.OperationHelperAsync( nameof(ExecuteAsync), diff --git a/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs b/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs index da3869ce6..a037ed5bb 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Cosmos { using System; using System.Diagnostics; - using System.Globalization; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -92,10 +91,7 @@ namespace Microsoft.Azure.Cosmos return this.body; } - set - { - this.body = value; - } + set => this.body = value; } /// diff --git a/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperationContext.cs b/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperationContext.cs index 4cc77fd00..f384b0449 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperationContext.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperationContext.cs @@ -23,7 +23,7 @@ namespace Microsoft.Azure.Cosmos private readonly IDocumentClientRetryPolicy retryPolicy; - private TaskCompletionSource taskCompletionSource = new TaskCompletionSource(); + private readonly TaskCompletionSource taskCompletionSource = new TaskCompletionSource(); public ItemBatchOperationContext( string partitionKeyRangeId, diff --git a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchExecutionResult.cs b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchExecutionResult.cs index a8778cd0b..8107610d0 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchExecutionResult.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchExecutionResult.cs @@ -25,10 +25,13 @@ namespace Microsoft.Azure.Cosmos this.Operations = operations; } - internal bool IsSplit() => this.ServerResponse != null && - this.ServerResponse.StatusCode == HttpStatusCode.Gone - && (this.ServerResponse.SubStatusCode == Documents.SubStatusCodes.CompletingSplit - || this.ServerResponse.SubStatusCode == Documents.SubStatusCodes.CompletingPartitionMigration - || this.ServerResponse.SubStatusCode == Documents.SubStatusCodes.PartitionKeyRangeGone); + internal bool IsSplit() + { + return this.ServerResponse != null && + this.ServerResponse.StatusCode == HttpStatusCode.Gone + && (this.ServerResponse.SubStatusCode == Documents.SubStatusCodes.CompletingSplit + || this.ServerResponse.SubStatusCode == Documents.SubStatusCodes.CompletingPartitionMigration + || this.ServerResponse.SubStatusCode == Documents.SubStatusCodes.PartitionKeyRangeGone); + } } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs index 352323685..317328fb9 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs @@ -97,7 +97,7 @@ namespace Microsoft.Azure.Cosmos TransactionalBatchOperationResult result = this.resultsByOperationIndex[index]; - T resource = default(T); + T resource = default; if (result.ResourceStream != null) { resource = this.SerializerCore.FromStream(result.ResourceStream); diff --git a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs index 546092288..e4c83b278 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs @@ -5,10 +5,8 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Net; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Documents; internal sealed class PartitionKeyRangeServerBatchRequest : ServerBatchRequest { diff --git a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatch.cs b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatch.cs index 76e008507..1c4acf5da 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatch.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatch.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System.Collections.Generic; using System.IO; using System.Net; using System.Threading; @@ -217,7 +216,7 @@ namespace Microsoft.Azure.Cosmos /// The transactional batch instance with the operation added. public abstract TransactionalBatch PatchItem( string id, - IReadOnlyList patchOperations, + System.Collections.Generic.IReadOnlyList patchOperations, TransactionalBatchItemRequestOptions requestOptions = null); #endif @@ -249,7 +248,7 @@ namespace Microsoft.Azure.Cosmos /// Use on the response returned to ensure that the transactional batch succeeded. /// public abstract Task ExecuteAsync( - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Executes the transactional batch at the Azure Cosmos service as an asynchronous operation. @@ -281,6 +280,6 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task ExecuteAsync( TransactionalBatchRequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); } } diff --git a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchItemRequestOptions.cs b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchItemRequestOptions.cs index 24aaeeebd..0fcec01d4 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchItemRequestOptions.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchItemRequestOptions.cs @@ -47,15 +47,17 @@ namespace Microsoft.Azure.Cosmos return null; } - RequestOptions requestOptions = itemRequestOptions as RequestOptions; - TransactionalBatchItemRequestOptions batchItemRequestOptions = new TransactionalBatchItemRequestOptions(); - batchItemRequestOptions.IndexingDirective = itemRequestOptions.IndexingDirective; - batchItemRequestOptions.IfMatchEtag = itemRequestOptions.IfMatchEtag; - batchItemRequestOptions.IfNoneMatchEtag = itemRequestOptions.IfNoneMatchEtag; - batchItemRequestOptions.Properties = itemRequestOptions.Properties; - batchItemRequestOptions.EnableContentResponseOnWrite = itemRequestOptions.EnableContentResponseOnWrite; - batchItemRequestOptions.EnableContentResponseOnRead = itemRequestOptions.EnableContentResponseOnRead; - batchItemRequestOptions.IsEffectivePartitionKeyRouting = itemRequestOptions.IsEffectivePartitionKeyRouting; + RequestOptions requestOptions = itemRequestOptions; + TransactionalBatchItemRequestOptions batchItemRequestOptions = new TransactionalBatchItemRequestOptions + { + IndexingDirective = itemRequestOptions.IndexingDirective, + IfMatchEtag = itemRequestOptions.IfMatchEtag, + IfNoneMatchEtag = itemRequestOptions.IfNoneMatchEtag, + Properties = itemRequestOptions.Properties, + EnableContentResponseOnWrite = itemRequestOptions.EnableContentResponseOnWrite, + EnableContentResponseOnRead = itemRequestOptions.EnableContentResponseOnRead, + IsEffectivePartitionKeyRouting = itemRequestOptions.IsEffectivePartitionKeyRouting + }; return batchItemRequestOptions; } } diff --git a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchOperationResult.cs b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchOperationResult.cs index a76b9c844..9a936ee7d 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchOperationResult.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchOperationResult.cs @@ -208,7 +208,7 @@ namespace Microsoft.Azure.Cosmos RetryAfter = this.RetryAfter, RequestCharge = this.RequestCharge, }; - + ResponseMessage responseMessage = new ResponseMessage( statusCode: this.StatusCode, requestMessage: null, diff --git a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs index 5acc8515a..77f0467bd 100644 --- a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs @@ -148,13 +148,7 @@ namespace Microsoft.Azure.Cosmos /// /// 0-based index of the operation in the batch whose result needs to be returned. /// Result of operation at the provided index in the batch. - public virtual TransactionalBatchOperationResult this[int index] - { - get - { - return this.results[index]; - } - } + public virtual TransactionalBatchOperationResult this[int index] => this.results[index]; /// /// Gets the result of the operation at the provided index in the batch - the returned result has a Resource of provided type. @@ -166,7 +160,7 @@ namespace Microsoft.Azure.Cosmos { TransactionalBatchOperationResult result = this.results[index]; - T resource = default(T); + T resource = default; if (result.ResourceStream != null) { resource = this.SerializerCore.FromStream(result.ResourceStream); @@ -378,9 +372,10 @@ namespace Microsoft.Azure.Cosmos responseMessage.Headers, responseMessage.DiagnosticsContext, serverRequest.Operations, - serializer); - - response.results = results; + serializer) + { + results = results + }; return response; } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedIteratorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedIteratorCore.cs index 3c4d47508..fbf8c49fc 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedIteratorCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedIteratorCore.cs @@ -120,7 +120,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed } } - public override CosmosElement GetCosmosElementContinuationToken() => CosmosElement.Parse(this.FeedRangeContinuation.ToString()); + public override CosmosElement GetCosmosElementContinuationToken() + { + return CosmosElement.Parse(this.FeedRangeContinuation.ToString()); + } private async Task ReadNextInternalAsync( CosmosDiagnosticsContext diagnosticsScope, diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCore.cs index 01a40e292..ec9b54f67 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCore.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed { using System; - using System.Net; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; @@ -35,14 +34,17 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed public override bool HasMoreResults => this.hasMoreResultsInternal; - public override CosmosElement GetCosmosElementContinuationToken() => throw new NotImplementedException(); + public override CosmosElement GetCosmosElementContinuationToken() + { + throw new NotImplementedException(); + } /// /// Get the next set of results from the cosmos service /// /// (Optional) representing request cancellation. /// A change feed response from cosmos service - public override async Task ReadNextAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override async Task ReadNextAsync(CancellationToken cancellationToken = default) { ResponseMessage responseMessage = await this.clientContext.ProcessResourceOperationStreamAsync( cosmosContainerCore: this.container, diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedRangeExtractor.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedRangeExtractor.cs index 79d674d24..5ad4053c9 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedRangeExtractor.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedRangeExtractor.cs @@ -14,15 +14,29 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed { } - public override FeedRange Visit(ChangeFeedStartFromNow startFromNow) => startFromNow.FeedRange; + public override FeedRange Visit(ChangeFeedStartFromNow startFromNow) + { + return startFromNow.FeedRange; + } - public override FeedRange Visit(ChangeFeedStartFromTime startFromTime) => startFromTime.FeedRange; + public override FeedRange Visit(ChangeFeedStartFromTime startFromTime) + { + return startFromTime.FeedRange; + } public override FeedRange Visit(ChangeFeedStartFromContinuation startFromContinuation) - => throw new NotSupportedException($"{nameof(ChangeFeedStartFromContinuation)} does not have a feed range."); + { + throw new NotSupportedException($"{nameof(ChangeFeedStartFromContinuation)} does not have a feed range."); + } - public override FeedRange Visit(ChangeFeedStartFromBeginning startFromBeginning) => startFromBeginning.FeedRange; + public override FeedRange Visit(ChangeFeedStartFromBeginning startFromBeginning) + { + return startFromBeginning.FeedRange; + } - public override FeedRange Visit(ChangeFeedStartFromContinuationAndFeedRange startFromContinuationAndFeedRange) => startFromContinuationAndFeedRange.FeedRange; + public override FeedRange Visit(ChangeFeedStartFromContinuationAndFeedRange startFromContinuationAndFeedRange) + { + return startFromContinuationAndFeedRange.FeedRange; + } } } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFrom.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFrom.cs index 8de9024bc..7f121af91 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFrom.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFrom.cs @@ -34,7 +34,10 @@ namespace Microsoft.Azure.Cosmos /// Creates a that tells the ChangeFeed operation to start reading changes from this moment onward. /// /// A that tells the ChangeFeed operation to start reading changes from this moment onward. - public static ChangeFeedStartFrom Now() => Now(FeedRangeEpk.FullRange); + public static ChangeFeedStartFrom Now() + { + return Now(FeedRangeEpk.FullRange); + } /// /// Creates a that tells the ChangeFeed operation to start reading changes from this moment onward. @@ -56,7 +59,10 @@ namespace Microsoft.Azure.Cosmos /// /// The time (in UTC) to start reading from. /// A that tells the ChangeFeed operation to start reading changes from some point in time onward. - public static ChangeFeedStartFrom Time(DateTime dateTimeUtc) => Time(dateTimeUtc, FeedRangeEpk.FullRange); + public static ChangeFeedStartFrom Time(DateTime dateTimeUtc) + { + return Time(dateTimeUtc, FeedRangeEpk.FullRange); + } /// /// Creates a that tells the ChangeFeed operation to start reading changes from some point in time onward. @@ -79,13 +85,19 @@ namespace Microsoft.Azure.Cosmos /// /// The continuation to resume from. /// A that tells the ChangeFeed operation to start reading changes from a save point. - public static ChangeFeedStartFrom ContinuationToken(string continuationToken) => new ChangeFeedStartFromContinuation(continuationToken); + public static ChangeFeedStartFrom ContinuationToken(string continuationToken) + { + return new ChangeFeedStartFromContinuation(continuationToken); + } /// /// Creates a that tells the ChangeFeed operation to start from the beginning of time. /// /// A that tells the ChangeFeed operation to start reading changes from the beginning of time. - public static ChangeFeedStartFrom Beginning() => Beginning(FeedRangeEpk.FullRange); + public static ChangeFeedStartFrom Beginning() + { + return Beginning(FeedRangeEpk.FullRange); + } /// /// Creates a that tells the ChangeFeed operation to start from the beginning of time. diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromBeginning.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromBeginning.cs index 643a122a0..74639910b 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromBeginning.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromBeginning.cs @@ -26,8 +26,14 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed /// public FeedRangeInternal FeedRange { get; } - internal override void Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override void Accept(ChangeFeedStartFromVisitor visitor) + { + visitor.Visit(this); + } - internal override TResult Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override TResult Accept(ChangeFeedStartFromVisitor visitor) + { + return visitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuation.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuation.cs index feabbad1b..eadebfdbb 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuation.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuation.cs @@ -32,8 +32,14 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed /// public string Continuation { get; } - internal override void Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override void Accept(ChangeFeedStartFromVisitor visitor) + { + visitor.Visit(this); + } - internal override TResult Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override TResult Accept(ChangeFeedStartFromVisitor visitor) + { + return visitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuationAndFeedRange.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuationAndFeedRange.cs index c07bcc270..80a55b167 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuationAndFeedRange.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromContinuationAndFeedRange.cs @@ -21,8 +21,14 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed public FeedRangeInternal FeedRange { get; } - internal override void Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override void Accept(ChangeFeedStartFromVisitor visitor) + { + visitor.Visit(this); + } - internal override TResult Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override TResult Accept(ChangeFeedStartFromVisitor visitor) + { + return visitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromNow.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromNow.cs index 598ac1cae..0111012f7 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromNow.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromNow.cs @@ -26,8 +26,14 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed /// public FeedRangeInternal FeedRange { get; } - internal override void Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override void Accept(ChangeFeedStartFromVisitor visitor) + { + visitor.Visit(this); + } - internal override TResult Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override TResult Accept(ChangeFeedStartFromVisitor visitor) + { + return visitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromTime.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromTime.cs index 26aeb1771..b8f83a38a 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromTime.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedStartFromTime.cs @@ -38,8 +38,14 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed /// public FeedRangeInternal FeedRange { get; } - internal override void Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override void Accept(ChangeFeedStartFromVisitor visitor) + { + visitor.Visit(this); + } - internal override TResult Accept(ChangeFeedStartFromVisitor visitor) => visitor.Visit(this); + internal override TResult Accept(ChangeFeedStartFromVisitor visitor) + { + return visitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedContinuationToken.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedContinuationToken.cs index 07ddc8cc8..e560be0e6 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedContinuationToken.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedContinuationToken.cs @@ -44,10 +44,21 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed string minInclusive, string maxExclusive) { - if (string.IsNullOrWhiteSpace(containerRid)) throw new ArgumentNullException(nameof(containerRid)); + if (string.IsNullOrWhiteSpace(containerRid)) + { + throw new ArgumentNullException(nameof(containerRid)); + } // MinInclusive can be an empty string - if (minInclusive == null) throw new ArgumentNullException(nameof(minInclusive)); - if (string.IsNullOrWhiteSpace(maxExclusive)) throw new ArgumentNullException(nameof(maxExclusive)); + if (minInclusive == null) + { + throw new ArgumentNullException(nameof(minInclusive)); + } + + if (string.IsNullOrWhiteSpace(maxExclusive)) + { + throw new ArgumentNullException(nameof(maxExclusive)); + } + return StandByFeedContinuationToken.SerializeTokens(new CompositeContinuationToken[1] { StandByFeedContinuationToken.CreateCompositeContinuationTokenForRange(minInclusive, maxExclusive, null) }); } @@ -66,8 +77,15 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed string initialStandByFeedContinuationToken, PartitionKeyRangeCacheDelegate pkRangeCacheDelegate) { - if (string.IsNullOrWhiteSpace(containerRid)) throw new ArgumentNullException(nameof(containerRid)); - if (pkRangeCacheDelegate == null) throw new ArgumentNullException(nameof(pkRangeCacheDelegate)); + if (string.IsNullOrWhiteSpace(containerRid)) + { + throw new ArgumentNullException(nameof(containerRid)); + } + + if (pkRangeCacheDelegate == null) + { + throw new ArgumentNullException(nameof(pkRangeCacheDelegate)); + } this.containerRid = containerRid; this.pkRangeCacheDelegate = pkRangeCacheDelegate; @@ -118,7 +136,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed private void HandleSplit(IReadOnlyList keyRanges) { - if (keyRanges == null) throw new ArgumentNullException(nameof(keyRanges)); + if (keyRanges == null) + { + throw new ArgumentNullException(nameof(keyRanges)); + } // Update current Documents.PartitionKeyRange firstRange = keyRanges[0]; diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedIteratorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedIteratorCore.cs index 1c3b8fb96..0531c4d0b 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedIteratorCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeed/StandByFeedIteratorCore.cs @@ -34,7 +34,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedRequestOptions options) { - if (container == null) throw new ArgumentNullException(nameof(container)); + if (container == null) + { + throw new ArgumentNullException(nameof(container)); + } this.clientContext = clientContext; this.container = container; @@ -54,7 +57,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed /// /// (Optional) representing request cancellation. /// A query response from cosmos service - public override async Task ReadNextAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override async Task ReadNextAsync(CancellationToken cancellationToken = default) { string firstNotModifiedKeyRangeId = null; string currentKeyRangeId; @@ -153,7 +156,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed /// internal async Task ShouldRetryFailureAsync( ResponseMessage response, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.NotModified) { diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedOptions.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedOptions.cs index 4294051f7..45f43fb51 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedOptions.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedOptions.cs @@ -89,10 +89,7 @@ namespace Microsoft.Azure.Cosmos /// public DateTime? StartTime { - get - { - return this.startTime; - } + get => this.startTime; set { diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Bootstrapping/BootstrapperCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Bootstrapping/BootstrapperCore.cs index ee389843b..e317a64e7 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Bootstrapping/BootstrapperCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Bootstrapping/BootstrapperCore.cs @@ -22,10 +22,25 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Bootstrapping public BootstrapperCore(PartitionSynchronizer synchronizer, DocumentServiceLeaseStore leaseStore, TimeSpan lockTime, TimeSpan sleepTime) { - if (synchronizer == null) throw new ArgumentNullException(nameof(synchronizer)); - if (leaseStore == null) throw new ArgumentNullException(nameof(leaseStore)); - if (lockTime <= TimeSpan.Zero) throw new ArgumentException("should be positive", nameof(lockTime)); - if (sleepTime <= TimeSpan.Zero) throw new ArgumentException("should be positive", nameof(sleepTime)); + if (synchronizer == null) + { + throw new ArgumentNullException(nameof(synchronizer)); + } + + if (leaseStore == null) + { + throw new ArgumentNullException(nameof(leaseStore)); + } + + if (lockTime <= TimeSpan.Zero) + { + throw new ArgumentException("should be positive", nameof(lockTime)); + } + + if (sleepTime <= TimeSpan.Zero) + { + throw new ArgumentException("should be positive", nameof(sleepTime)); + } this.synchronizer = synchronizer; this.leaseStore = leaseStore; @@ -38,7 +53,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Bootstrapping while (true) { bool initialized = await this.leaseStore.IsInitializedAsync().ConfigureAwait(false); - if (initialized) break; + if (initialized) + { + break; + } bool isLockAcquired = await this.leaseStore.AcquireInitializationLockAsync(this.lockTime).ConfigureAwait(false); diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedEstimatorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedEstimatorCore.cs index 3aed14db3..1384efdfb 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedEstimatorCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedEstimatorCore.cs @@ -37,8 +37,15 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed ChangesEstimationHandler initialEstimateDelegate, TimeSpan? estimatorPeriod) { - if (initialEstimateDelegate == null) throw new ArgumentNullException(nameof(initialEstimateDelegate)); - if (estimatorPeriod.HasValue && estimatorPeriod.Value <= TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(estimatorPeriod)); + if (initialEstimateDelegate == null) + { + throw new ArgumentNullException(nameof(initialEstimateDelegate)); + } + + if (estimatorPeriod.HasValue && estimatorPeriod.Value <= TimeSpan.Zero) + { + throw new ArgumentOutOfRangeException(nameof(estimatorPeriod)); + } this.initialEstimateDelegate = initialEstimateDelegate; this.estimatorPeriod = estimatorPeriod; @@ -62,8 +69,15 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed ChangeFeedProcessorOptions changeFeedProcessorOptions, ContainerInternal monitoredContainer) { - if (monitoredContainer == null) throw new ArgumentNullException(nameof(monitoredContainer)); - if (leaseContainer == null && customDocumentServiceLeaseStoreManager == null) throw new ArgumentNullException(nameof(leaseContainer)); + if (monitoredContainer == null) + { + throw new ArgumentNullException(nameof(monitoredContainer)); + } + + if (leaseContainer == null && customDocumentServiceLeaseStoreManager == null) + { + throw new ArgumentNullException(nameof(leaseContainer)); + } this.documentServiceLeaseStoreManager = customDocumentServiceLeaseStoreManager; this.leaseContainer = leaseContainer; diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs index 32841ba10..5271eea93 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorBuilder.cs @@ -46,8 +46,10 @@ namespace Microsoft.Azure.Cosmos ChangeFeedProcessorOptions, ContainerInternal> applyBuilderConfiguration) { - this.changeFeedLeaseOptions = new ChangeFeedLeaseOptions(); - this.changeFeedLeaseOptions.LeasePrefix = processorName; + this.changeFeedLeaseOptions = new ChangeFeedLeaseOptions + { + LeasePrefix = processorName + }; this.monitoredContainer = container; this.changeFeedProcessor = changeFeedProcessor; this.applyBuilderConfiguration = applyBuilderConfiguration; @@ -92,7 +94,10 @@ namespace Microsoft.Azure.Cosmos /// The instance of to use. public ChangeFeedProcessorBuilder WithPollInterval(TimeSpan pollInterval) { - if (pollInterval == null) throw new ArgumentNullException(nameof(pollInterval)); + if (pollInterval == null) + { + throw new ArgumentNullException(nameof(pollInterval)); + } this.changeFeedProcessorOptions = this.changeFeedProcessorOptions ?? new ChangeFeedProcessorOptions(); this.changeFeedProcessorOptions.FeedPollDelay = pollInterval; @@ -130,7 +135,10 @@ namespace Microsoft.Azure.Cosmos /// The instance of to use. public ChangeFeedProcessorBuilder WithStartTime(DateTime startTime) { - if (startTime == null) throw new ArgumentNullException(nameof(startTime)); + if (startTime == null) + { + throw new ArgumentNullException(nameof(startTime)); + } this.changeFeedProcessorOptions = this.changeFeedProcessorOptions ?? new ChangeFeedProcessorOptions(); this.changeFeedProcessorOptions.StartTime = startTime; @@ -144,7 +152,10 @@ namespace Microsoft.Azure.Cosmos /// An instance of . public ChangeFeedProcessorBuilder WithMaxItems(int maxItemCount) { - if (maxItemCount <= 0) throw new ArgumentOutOfRangeException(nameof(maxItemCount)); + if (maxItemCount <= 0) + { + throw new ArgumentOutOfRangeException(nameof(maxItemCount)); + } this.changeFeedProcessorOptions = this.changeFeedProcessorOptions ?? new ChangeFeedProcessorOptions(); this.changeFeedProcessorOptions.MaxItemCount = maxItemCount; @@ -158,9 +169,20 @@ namespace Microsoft.Azure.Cosmos /// The instance of to use. public ChangeFeedProcessorBuilder WithLeaseContainer(Container leaseContainer) { - if (leaseContainer == null) throw new ArgumentNullException(nameof(leaseContainer)); - if (this.leaseContainer != null) throw new InvalidOperationException("The builder already defined a lease container."); - if (this.LeaseStoreManager != null) throw new InvalidOperationException("The builder already defined an in-memory lease container instance."); + if (leaseContainer == null) + { + throw new ArgumentNullException(nameof(leaseContainer)); + } + + if (this.leaseContainer != null) + { + throw new InvalidOperationException("The builder already defined a lease container."); + } + + if (this.LeaseStoreManager != null) + { + throw new InvalidOperationException("The builder already defined an in-memory lease container instance."); + } this.leaseContainer = (ContainerInternal)leaseContainer; return this; @@ -175,8 +197,15 @@ namespace Microsoft.Azure.Cosmos /// The instance of to use. internal virtual ChangeFeedProcessorBuilder WithInMemoryLeaseContainer() { - if (this.leaseContainer != null) throw new InvalidOperationException("The builder already defined a lease container."); - if (this.LeaseStoreManager != null) throw new InvalidOperationException("The builder already defined an in-memory lease container instance."); + if (this.leaseContainer != null) + { + throw new InvalidOperationException("The builder already defined a lease container."); + } + + if (this.LeaseStoreManager != null) + { + throw new InvalidOperationException("The builder already defined an in-memory lease container instance."); + } if (string.IsNullOrEmpty(this.InstanceName)) { @@ -204,7 +233,10 @@ namespace Microsoft.Azure.Cosmos internal virtual ChangeFeedProcessorBuilder WithMonitoredContainerRid(string monitoredContainerRid) { - if (monitoredContainerRid != null) throw new ArgumentNullException(nameof(monitoredContainerRid)); + if (monitoredContainerRid != null) + { + throw new ArgumentNullException(nameof(monitoredContainerRid)); + } this.monitoredContainerRid = monitoredContainerRid; return this; diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs index 001943e7d..f0e11c572 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs @@ -30,7 +30,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed public ChangeFeedProcessorCore(ChangeFeedObserverFactory observerFactory) { - if (observerFactory == null) throw new ArgumentNullException(nameof(observerFactory)); + if (observerFactory == null) + { + throw new ArgumentNullException(nameof(observerFactory)); + } this.observerFactory = observerFactory; } @@ -44,9 +47,20 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed ChangeFeedProcessorOptions changeFeedProcessorOptions, ContainerInternal monitoredContainer) { - if (monitoredContainer == null) throw new ArgumentNullException(nameof(monitoredContainer)); - if (customDocumentServiceLeaseStoreManager == null && leaseContainer == null) throw new ArgumentNullException(nameof(leaseContainer)); - if (instanceName == null) throw new ArgumentNullException("InstanceName is required for the processor to initialize."); + if (monitoredContainer == null) + { + throw new ArgumentNullException(nameof(monitoredContainer)); + } + + if (customDocumentServiceLeaseStoreManager == null && leaseContainer == null) + { + throw new ArgumentNullException(nameof(leaseContainer)); + } + + if (instanceName == null) + { + throw new ArgumentNullException("InstanceName is required for the processor to initialize."); + } this.documentServiceLeaseStoreManager = customDocumentServiceLeaseStoreManager; this.leaseContainer = leaseContainer; @@ -109,7 +123,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed } RequestOptionsFactory requestOptionsFactory = isPartitioned && !isMigratedFixed ? - (RequestOptionsFactory)new PartitionedByIdCollectionRequestOptionsFactory() : + new PartitionedByIdCollectionRequestOptionsFactory() : (RequestOptionsFactory)new SinglePartitionRequestOptionsFactory(); DocumentServiceLeaseStoreManagerBuilder leaseStoreManagerBuilder = new DocumentServiceLeaseStoreManagerBuilder() diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Configuration/ChangeFeedProcessorOptions.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Configuration/ChangeFeedProcessorOptions.cs index 9d74f0b8d..28d4aff36 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Configuration/ChangeFeedProcessorOptions.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Configuration/ChangeFeedProcessorOptions.cs @@ -64,15 +64,15 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Configuration /// public DateTime? StartTime { - get - { - return this.startTime; - } + get => this.startTime; set { if (value.HasValue && value.Value.Kind == DateTimeKind.Unspecified) + { throw new ArgumentException("StartTime cannot have DateTimeKind.Unspecified", nameof(value)); + } + this.startTime = value; } } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/DocDBErrors/SubStatusHelpers.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/DocDBErrors/SubStatusHelpers.cs index 1f98fbd0c..0542005f2 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/DocDBErrors/SubStatusHelpers.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/DocDBErrors/SubStatusHelpers.cs @@ -16,9 +16,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.DocDBErrors string valueSubStatus = exception.ResponseHeaders.Get(subStatusHeaderName); if (!string.IsNullOrEmpty(valueSubStatus)) { - int subStatusCode; - if (int.TryParse(valueSubStatus, NumberStyles.Integer, CultureInfo.InvariantCulture, out subStatusCode)) + if (int.TryParse(valueSubStatus, NumberStyles.Integer, CultureInfo.InvariantCulture, out int subStatusCode)) + { return (SubStatusCodes)subStatusCode; + } } return SubStatusCodes.Unknown; diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/EqualPartitionsBalancingStrategy.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/EqualPartitionsBalancingStrategy.cs index bf44367da..7a5f4ac10 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/EqualPartitionsBalancingStrategy.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/EqualPartitionsBalancingStrategy.cs @@ -23,7 +23,11 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement public EqualPartitionsBalancingStrategy(string hostName, int minPartitionCount, int maxPartitionCount, TimeSpan leaseExpirationInterval) { - if (hostName == null) throw new ArgumentNullException(nameof(hostName)); + if (hostName == null) + { + throw new ArgumentNullException(nameof(hostName)); + } + this.hostName = hostName; this.minPartitionCount = minPartitionCount; this.maxPartitionCount = maxPartitionCount; @@ -32,15 +36,17 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement public override IEnumerable SelectLeasesToTake(IEnumerable allLeases) { - var workerToPartitionCount = new Dictionary(); - var expiredLeases = new List(); - var allPartitions = new Dictionary(); + Dictionary workerToPartitionCount = new Dictionary(); + List expiredLeases = new List(); + Dictionary allPartitions = new Dictionary(); this.CategorizeLeases(allLeases, allPartitions, expiredLeases, workerToPartitionCount); int partitionCount = allPartitions.Count; int workerCount = workerToPartitionCount.Count; if (partitionCount <= 0) + { return Enumerable.Empty(); + } int target = this.CalculateTargetPartitionCount(partitionCount, workerCount); int myCount = workerToPartitionCount[this.hostName]; @@ -59,7 +65,9 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement Math.Max(partitionsNeededForMe, 0)); if (partitionsNeededForMe <= 0) + { return Enumerable.Empty(); + } if (expiredLeases.Count > 0) { @@ -101,7 +109,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement private int CalculateTargetPartitionCount(int partitionCount, int workerCount) { - var target = 1; + int target = 1; if (partitionCount > workerCount) { target = (int)Math.Ceiling((double)partitionCount / workerCount); @@ -138,9 +146,8 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement } else { - var count = 0; string assignedTo = lease.Owner; - if (workerToPartitionCount.TryGetValue(assignedTo, out count)) + if (workerToPartitionCount.TryGetValue(assignedTo, out int count)) { workerToPartitionCount[assignedTo] = count + 1; } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/LeaseRenewerCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/LeaseRenewerCore.cs index 5955802af..da8e74de9 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/LeaseRenewerCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/LeaseRenewerCore.cs @@ -53,8 +53,11 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement { try { - var renewedLease = await this.leaseManager.RenewAsync(this.lease).ConfigureAwait(false); - if (renewedLease != null) this.lease = renewedLease; + DocumentServiceLease renewedLease = await this.leaseManager.RenewAsync(this.lease).ConfigureAwait(false); + if (renewedLease != null) + { + this.lease = renewedLease; + } DefaultTrace.TraceInformation("Lease with token {0}: renewed lease with result {1}", this.lease.CurrentLeaseToken, renewedLease != null); } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionControllerCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionControllerCore.cs index cc5d91cc0..2ff841a37 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionControllerCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionControllerCore.cs @@ -57,7 +57,11 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement try { DocumentServiceLease updatedLease = await this.leaseManager.AcquireAsync(lease).ConfigureAwait(false); - if (updatedLease != null) lease = updatedLease; + if (updatedLease != null) + { + lease = updatedLease; + } + DefaultTrace.TraceInformation("Lease with token {0}: acquired", lease.CurrentLeaseToken); } catch (Exception) @@ -92,8 +96,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement private async Task RemoveLeaseAsync(DocumentServiceLease lease) { - TaskCompletionSource worker; - if (!this.currentlyOwnedPartitions.TryRemove(lease.CurrentLeaseToken, out worker)) + if (!this.currentlyOwnedPartitions.TryRemove(lease.CurrentLeaseToken, out TaskCompletionSource worker)) { return; } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionLoadBalancerCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionLoadBalancerCore.cs index 9de8e0438..1516d142d 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionLoadBalancerCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/PartitionLoadBalancerCore.cs @@ -26,9 +26,20 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement LoadBalancingStrategy partitionLoadBalancingStrategy, TimeSpan leaseAcquireInterval) { - if (partitionController == null) throw new ArgumentNullException(nameof(partitionController)); - if (leaseContainer == null) throw new ArgumentNullException(nameof(leaseContainer)); - if (partitionLoadBalancingStrategy == null) throw new ArgumentNullException(nameof(partitionLoadBalancingStrategy)); + if (partitionController == null) + { + throw new ArgumentNullException(nameof(partitionController)); + } + + if (leaseContainer == null) + { + throw new ArgumentNullException(nameof(leaseContainer)); + } + + if (partitionLoadBalancingStrategy == null) + { + throw new ArgumentNullException(nameof(partitionLoadBalancingStrategy)); + } this.partitionController = partitionController; this.leaseContainer = leaseContainer; diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingLeaseTokenWork.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingLeaseTokenWork.cs index 1207ee304..181597ba3 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingLeaseTokenWork.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingLeaseTokenWork.cs @@ -18,7 +18,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement /// The amount of documents remaining to be processed public RemainingLeaseTokenWork(string leaseToken, long remainingWork) { - if (string.IsNullOrEmpty(leaseToken)) throw new ArgumentNullException(nameof(leaseToken)); + if (string.IsNullOrEmpty(leaseToken)) + { + throw new ArgumentNullException(nameof(leaseToken)); + } this.LeaseToken = leaseToken; this.RemainingWork = remainingWork; diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs index ebde58b00..fed7c87f5 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs @@ -17,7 +17,6 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement using Microsoft.Azure.Cosmos.ChangeFeed.LeaseManagement; using Microsoft.Azure.Cosmos.ChangeFeed.Utils; using Microsoft.Azure.Cosmos.Core.Trace; - using Microsoft.Azure.Cosmos.Query.Core; using Microsoft.Azure.Documents; using Newtonsoft.Json.Linq; @@ -58,7 +57,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement public override async Task GetEstimatedRemainingWorkAsync(CancellationToken cancellationToken) { IReadOnlyList leaseTokens = await this.GetEstimatedRemainingWorkPerLeaseTokenAsync(cancellationToken); - if (leaseTokens.Count == 0) return 1; + if (leaseTokens.Count == 0) + { + return 1; + } return leaseTokens.Sum(leaseToken => leaseToken.RemainingWork); } @@ -83,7 +85,11 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement DocumentServiceLease item = partition.Current; try { - if (string.IsNullOrEmpty(item?.CurrentLeaseToken)) continue; + if (string.IsNullOrEmpty(item?.CurrentLeaseToken)) + { + continue; + } + long result = await this.GetRemainingWorkAsync(item, cancellationToken); partialResults.Add(new RemainingLeaseTokenWork(item.CurrentLeaseToken, result)); } @@ -158,8 +164,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedManagement private static long TryConvertToNumber(string number) { - long parsed = 0; - if (!long.TryParse(number, NumberStyles.Number, CultureInfo.InvariantCulture, out parsed)) + if (!long.TryParse(number, NumberStyles.Number, CultureInfo.InvariantCulture, out long parsed)) { DefaultTrace.TraceWarning("Cannot parse number '{0}'.", number); return 0; diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/AutoCheckpointer.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/AutoCheckpointer.cs index c90e7de54..616990aaa 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/AutoCheckpointer.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/AutoCheckpointer.cs @@ -20,9 +20,14 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedProcessing public AutoCheckpointer(CheckpointFrequency checkpointFrequency, ChangeFeedObserver observer) { if (checkpointFrequency == null) + { throw new ArgumentNullException(nameof(checkpointFrequency)); + } + if (observer == null) + { throw new ArgumentNullException(nameof(observer)); + } this.checkpointFrequency = checkpointFrequency; this.observer = observer; @@ -59,11 +64,15 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedProcessing } if (this.processedDocCount >= this.checkpointFrequency.ProcessedDocumentCount) + { return true; + } TimeSpan delta = DateTime.UtcNow - this.lastCheckpointTime; if (delta >= this.checkpointFrequency.TimeInterval) + { return true; + } return false; } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/CheckpointerObserverFactory.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/CheckpointerObserverFactory.cs index 0a8c56885..2d93d3d7f 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/CheckpointerObserverFactory.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/CheckpointerObserverFactory.cs @@ -23,9 +23,14 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedProcessing public CheckpointerObserverFactory(ChangeFeedObserverFactory observerFactory, CheckpointFrequency checkpointFrequency) { if (observerFactory == null) + { throw new ArgumentNullException(nameof(observerFactory)); + } + if (checkpointFrequency == null) + { throw new ArgumentNullException(nameof(checkpointFrequency)); + } this.observerFactory = observerFactory; this.checkpointFrequency = checkpointFrequency; @@ -38,7 +43,10 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedProcessing public override ChangeFeedObserver CreateObserver() { ChangeFeedObserver observer = new ObserverExceptionWrappingChangeFeedObserverDecorator(this.observerFactory.CreateObserver()); - if (this.checkpointFrequency.ExplicitCheckpoint) return observer; + if (this.checkpointFrequency.ExplicitCheckpoint) + { + return observer; + } return new AutoCheckpointer(this.checkpointFrequency, observer); } diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedEstimatorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedEstimatorCore.cs index 5218d2265..648b4ec37 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedEstimatorCore.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedEstimatorCore.cs @@ -37,7 +37,9 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedProcessing catch (TaskCanceledException canceledException) { if (cancellationToken.IsCancellationRequested) + { throw; + } Extensions.TraceException(new Exception("exception within estimator", canceledException)); diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs index c5ce32f2e..e03fb799e 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs @@ -96,7 +96,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Utils public static async Task GetMonitoredContainerRidAsync( this Container monitoredContainer, string suggestedMonitoredRid, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!string.IsNullOrEmpty(suggestedMonitoredRid)) { diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/ParallelHelper.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/ParallelHelper.cs index 9048eb427..6570e0153 100644 --- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/ParallelHelper.cs +++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/ParallelHelper.cs @@ -18,7 +18,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Utils this IEnumerable source, Func worker, int maxParallelTaskCount = 0, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { Debug.Assert(source != null, "source is null"); Debug.Assert(worker != null, "worker is null"); diff --git a/Microsoft.Azure.Cosmos/src/ClientExtensions.cs b/Microsoft.Azure.Cosmos/src/ClientExtensions.cs index 83c520700..62eeb9ff5 100644 --- a/Microsoft.Azure.Cosmos/src/ClientExtensions.cs +++ b/Microsoft.Azure.Cosmos/src/ClientExtensions.cs @@ -16,7 +16,7 @@ namespace Microsoft.Azure.Cosmos public static async Task GetAsync(this HttpClient client, Uri uri, INameValueCollection additionalHeaders = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (uri == null) throw new ArgumentNullException("uri"); diff --git a/Microsoft.Azure.Cosmos/src/CosmosClient.cs b/Microsoft.Azure.Cosmos/src/CosmosClient.cs index 63957bbf5..8448c3a3d 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosClient.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosClient.cs @@ -5,9 +5,7 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.IO; using System.Net; - using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -376,7 +374,7 @@ namespace Microsoft.Azure.Cosmos string id, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(id)) { @@ -388,16 +386,16 @@ namespace Microsoft.Azure.Cosmos requestOptions, (diagnostics) => { - DatabaseProperties databaseProperties = this.PrepareDatabaseProperties(id); - ThroughputProperties throughputProperties = ThroughputProperties.CreateManualThroughput(throughput); + DatabaseProperties databaseProperties = this.PrepareDatabaseProperties(id); + ThroughputProperties throughputProperties = ThroughputProperties.CreateManualThroughput(throughput); - return this.CreateDatabaseInternalAsync( - databaseProperties: databaseProperties, - throughputProperties: throughputProperties, - requestOptions: requestOptions, - diagnosticsContext: diagnostics, - cancellationToken: cancellationToken); - }); + return this.CreateDatabaseInternalAsync( + databaseProperties: databaseProperties, + throughputProperties: throughputProperties, + requestOptions: requestOptions, + diagnosticsContext: diagnostics, + cancellationToken: cancellationToken); + }); } /// @@ -422,7 +420,7 @@ namespace Microsoft.Azure.Cosmos string id, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(id)) { @@ -480,14 +478,11 @@ namespace Microsoft.Azure.Cosmos string id, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { - if (string.IsNullOrEmpty(id)) - { - throw new ArgumentNullException(nameof(id)); - } - - return this.ClientContext.OperationHelperAsync( + return string.IsNullOrEmpty(id) + ? throw new ArgumentNullException(nameof(id)) + : this.ClientContext.OperationHelperAsync( nameof(CreateDatabaseIfNotExistsAsync), requestOptions, async (diagnostics) => @@ -566,7 +561,7 @@ namespace Microsoft.Azure.Cosmos string id, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { ThroughputProperties throughputProperties = ThroughputProperties.CreateManualThroughput(throughput); @@ -806,7 +801,7 @@ namespace Microsoft.Azure.Cosmos DatabaseProperties databaseProperties, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (databaseProperties == null) { @@ -875,7 +870,7 @@ namespace Microsoft.Azure.Cosmos DatabaseProperties databaseProperties, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (databaseProperties == null) { diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosBoolean.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosBoolean.cs index 30e10b0bb..93e205ab9 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosBoolean.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosBoolean.cs @@ -32,41 +32,86 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public bool Value { get; } - public override void Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override void Accept(ICosmosElementVisitor cosmosElementVisitor) + { + cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) + { + return cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) + { + return cosmosElementVisitor.Visit(this, input); + } - public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosBoolean cosmosBoolean && this.Equals(cosmosBoolean); + public override bool Equals(CosmosElement cosmosElement) + { + return cosmosElement is CosmosBoolean cosmosBoolean && this.Equals(cosmosBoolean); + } - public bool Equals(CosmosBoolean cosmosBoolean) => this.Value == cosmosBoolean.Value; + public bool Equals(CosmosBoolean cosmosBoolean) + { + return this.Value == cosmosBoolean.Value; + } - public override int GetHashCode() => this.Value ? TrueHash : FalseHash; + public override int GetHashCode() + { + return this.Value ? TrueHash : FalseHash; + } - public int CompareTo(CosmosBoolean cosmosBoolean) => this.Value.CompareTo(cosmosBoolean.Value); + public int CompareTo(CosmosBoolean cosmosBoolean) + { + return this.Value.CompareTo(cosmosBoolean.Value); + } - public static CosmosBoolean Create(bool boolean) => boolean ? CosmosBoolean.True : CosmosBoolean.False; + public static CosmosBoolean Create(bool boolean) + { + return boolean ? CosmosBoolean.True : CosmosBoolean.False; + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteBoolValue(this.Value); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteBoolValue(this.Value); + } - public static new CosmosBoolean CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.CreateFromBuffer(buffer); + public static new CosmosBoolean CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.CreateFromBuffer(buffer); + } - public static new CosmosBoolean Parse(string json) => CosmosElement.Parse(json); + public static new CosmosBoolean Parse(string json) + { + return CosmosElement.Parse(json); + } public static bool TryCreateFromBuffer( ReadOnlyMemory buffer, - out CosmosBoolean cosmosBoolean) => CosmosElement.TryCreateFromBuffer(buffer, out cosmosBoolean); + out CosmosBoolean cosmosBoolean) + { + return CosmosElement.TryCreateFromBuffer(buffer, out cosmosBoolean); + } public static bool TryParse( string json, - out CosmosBoolean cosmosBoolean) => CosmosElement.TryParse(json, out cosmosBoolean); + out CosmosBoolean cosmosBoolean) + { + return CosmosElement.TryParse(json, out cosmosBoolean); + } public static new class Monadic { - public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.Monadic.CreateFromBuffer(buffer); + public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.Monadic.CreateFromBuffer(buffer); + } - public static TryCatch Parse(string json) => CosmosElement.Monadic.Parse(json); + public static TryCatch Parse(string json) + { + return CosmosElement.Monadic.Parse(json); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElement.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElement.cs index 9d55ed8e4..0d7be9641 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElement.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElement.cs @@ -41,11 +41,14 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return Utf8StringHelpers.ToString(jsonWriter.GetResult()); } - public override bool Equals(object obj) => obj is CosmosElement cosmosElement && this.Equals(cosmosElement); + public override bool Equals(object obj) + { + return obj is CosmosElement cosmosElement && this.Equals(cosmosElement); + } public abstract bool Equals(CosmosElement cosmosElement); - public override abstract int GetHashCode(); + public abstract override int GetHashCode(); public int CompareTo(CosmosElement other) { @@ -121,7 +124,10 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return TryCatch.FromResult(typedCosmosElement); } - public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.Monadic.CreateFromBuffer(buffer); + public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.Monadic.CreateFromBuffer(buffer); + } public static TryCatch Parse(string serializedCosmosElement) where TCosmosElement : CosmosElement @@ -142,7 +148,10 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return CosmosElement.Monadic.CreateFromBuffer(buffer); } - public static TryCatch Parse(string serializedCosmosElement) => CosmosElement.Monadic.Parse(serializedCosmosElement); + public static TryCatch Parse(string serializedCosmosElement) + { + return CosmosElement.Monadic.Parse(serializedCosmosElement); + } } public static TCosmosElement CreateFromBuffer(ReadOnlyMemory buffer) @@ -154,7 +163,10 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return tryCreateFromBuffer.Result; } - public static CosmosElement CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.CreateFromBuffer(buffer); + public static CosmosElement CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.CreateFromBuffer(buffer); + } public static bool TryCreateFromBuffer(ReadOnlyMemory buffer, out TCosmosElement cosmosElement) where TCosmosElement : CosmosElement @@ -248,7 +260,10 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return a.Equals(b); } - public static bool operator !=(CosmosElement a, CosmosElement b) => !(a == b); + public static bool operator !=(CosmosElement a, CosmosElement b) + { + return !(a == b); + } private sealed class CosmosElementToTypeOrder : ICosmosElementVisitor { @@ -258,14 +273,45 @@ namespace Microsoft.Azure.Cosmos.CosmosElements { } - public int Visit(CosmosNull cosmosNull) => 0; - public int Visit(CosmosBoolean cosmosBoolean) => 1; - public int Visit(CosmosNumber cosmosNumber) => 2; - public int Visit(CosmosString cosmosString) => 3; - public int Visit(CosmosArray cosmosArray) => 4; - public int Visit(CosmosObject cosmosObject) => 5; - public int Visit(CosmosGuid cosmosGuid) => 6; - public int Visit(CosmosBinary cosmosBinary) => 7; + public int Visit(CosmosNull cosmosNull) + { + return 0; + } + + public int Visit(CosmosBoolean cosmosBoolean) + { + return 1; + } + + public int Visit(CosmosNumber cosmosNumber) + { + return 2; + } + + public int Visit(CosmosString cosmosString) + { + return 3; + } + + public int Visit(CosmosArray cosmosArray) + { + return 4; + } + + public int Visit(CosmosObject cosmosObject) + { + return 5; + } + + public int Visit(CosmosGuid cosmosGuid) + { + return 6; + } + + public int Visit(CosmosBinary cosmosBinary) + { + return 7; + } } private sealed class CosmosElementWithinTypeComparer : ICosmosElementVisitor @@ -276,14 +322,45 @@ namespace Microsoft.Azure.Cosmos.CosmosElements { } - public int Visit(CosmosArray cosmosArray, CosmosElement input) => cosmosArray.CompareTo((CosmosArray)input); - public int Visit(CosmosBinary cosmosBinary, CosmosElement input) => cosmosBinary.CompareTo((CosmosBinary)input); - public int Visit(CosmosBoolean cosmosBoolean, CosmosElement input) => cosmosBoolean.CompareTo((CosmosBoolean)input); - public int Visit(CosmosGuid cosmosGuid, CosmosElement input) => cosmosGuid.CompareTo((CosmosGuid)input); - public int Visit(CosmosNull cosmosNull, CosmosElement input) => cosmosNull.CompareTo((CosmosNull)input); - public int Visit(CosmosNumber cosmosNumber, CosmosElement input) => cosmosNumber.CompareTo((CosmosNumber)input); - public int Visit(CosmosObject cosmosObject, CosmosElement input) => cosmosObject.CompareTo((CosmosObject)input); - public int Visit(CosmosString cosmosString, CosmosElement input) => cosmosString.CompareTo((CosmosString)input); + public int Visit(CosmosArray cosmosArray, CosmosElement input) + { + return cosmosArray.CompareTo((CosmosArray)input); + } + + public int Visit(CosmosBinary cosmosBinary, CosmosElement input) + { + return cosmosBinary.CompareTo((CosmosBinary)input); + } + + public int Visit(CosmosBoolean cosmosBoolean, CosmosElement input) + { + return cosmosBoolean.CompareTo((CosmosBoolean)input); + } + + public int Visit(CosmosGuid cosmosGuid, CosmosElement input) + { + return cosmosGuid.CompareTo((CosmosGuid)input); + } + + public int Visit(CosmosNull cosmosNull, CosmosElement input) + { + return cosmosNull.CompareTo((CosmosNull)input); + } + + public int Visit(CosmosNumber cosmosNumber, CosmosElement input) + { + return cosmosNumber.CompareTo((CosmosNumber)input); + } + + public int Visit(CosmosObject cosmosObject, CosmosElement input) + { + return cosmosObject.CompareTo((CosmosObject)input); + } + + public int Visit(CosmosString cosmosString, CosmosElement input) + { + return cosmosString.CompareTo((CosmosString)input); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosGuid.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosGuid.cs index ee5ea39a4..e11241f11 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosGuid.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosGuid.cs @@ -28,15 +28,30 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public abstract Guid Value { get; } - public override void Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override void Accept(ICosmosElementVisitor cosmosElementVisitor) + { + cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) + { + return cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) + { + return cosmosElementVisitor.Visit(this, input); + } - public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosGuid cosmosGuid && this.Equals(cosmosGuid); + public override bool Equals(CosmosElement cosmosElement) + { + return cosmosElement is CosmosGuid cosmosGuid && this.Equals(cosmosGuid); + } - public bool Equals(CosmosGuid cosmosGuid) => this.Value == cosmosGuid.Value; + public bool Equals(CosmosGuid cosmosGuid) + { + return this.Value == cosmosGuid.Value; + } public override int GetHashCode() { @@ -45,7 +60,10 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return (int)hash; } - public int CompareTo(CosmosGuid cosmosGuid) => this.Value.CompareTo(cosmosGuid.Value); + public int CompareTo(CosmosGuid cosmosGuid) + { + return this.Value.CompareTo(cosmosGuid.Value); + } public static CosmosGuid Create( IJsonNavigator jsonNavigator, @@ -54,27 +72,51 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return new LazyCosmosGuid(jsonNavigator, jsonNavigatorNode); } - public static CosmosGuid Create(Guid value) => new EagerCosmosGuid(value); + public static CosmosGuid Create(Guid value) + { + return new EagerCosmosGuid(value); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteGuidValue(this.Value); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteGuidValue(this.Value); + } - public static new CosmosGuid CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.CreateFromBuffer(buffer); + public static new CosmosGuid CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.CreateFromBuffer(buffer); + } - public static new CosmosGuid Parse(string json) => CosmosElement.Parse(json); + public static new CosmosGuid Parse(string json) + { + return CosmosElement.Parse(json); + } public static bool TryCreateFromBuffer( ReadOnlyMemory buffer, - out CosmosGuid cosmosGuid) => CosmosElement.TryCreateFromBuffer(buffer, out cosmosGuid); + out CosmosGuid cosmosGuid) + { + return CosmosElement.TryCreateFromBuffer(buffer, out cosmosGuid); + } public static bool TryParse( string json, - out CosmosGuid cosmosGuid) => CosmosElement.TryParse(json, out cosmosGuid); + out CosmosGuid cosmosGuid) + { + return CosmosElement.TryParse(json, out cosmosGuid); + } public static new class Monadic { - public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.Monadic.CreateFromBuffer(buffer); + public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.Monadic.CreateFromBuffer(buffer); + } - public static TryCatch Parse(string json) => CosmosElement.Monadic.Parse(json); + public static TryCatch Parse(string json) + { + return CosmosElement.Monadic.Parse(json); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNull.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNull.cs index 6f41361bb..4f192d28e 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNull.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNull.cs @@ -27,41 +27,86 @@ namespace Microsoft.Azure.Cosmos.CosmosElements { } - public override void Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override void Accept(ICosmosElementVisitor cosmosElementVisitor) + { + cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) + { + return cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) + { + return cosmosElementVisitor.Visit(this, input); + } - public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosNull cosmosNull && this.Equals(cosmosNull); + public override bool Equals(CosmosElement cosmosElement) + { + return cosmosElement is CosmosNull cosmosNull && this.Equals(cosmosNull); + } - public bool Equals(CosmosNull cosmosNull) => true; + public bool Equals(CosmosNull cosmosNull) + { + return true; + } - public static CosmosNull Create() => CosmosNull.Singleton; + public static CosmosNull Create() + { + return CosmosNull.Singleton; + } - public override int GetHashCode() => (int)Hash; + public override int GetHashCode() + { + return (int)Hash; + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteNullValue(); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteNullValue(); + } - public static new CosmosNull CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.CreateFromBuffer(buffer); + public static new CosmosNull CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.CreateFromBuffer(buffer); + } - public static new CosmosNull Parse(string json) => CosmosElement.Parse(json); + public static new CosmosNull Parse(string json) + { + return CosmosElement.Parse(json); + } public static bool TryCreateFromBuffer( ReadOnlyMemory buffer, - out CosmosNull cosmosNull) => CosmosElement.TryCreateFromBuffer(buffer, out cosmosNull); + out CosmosNull cosmosNull) + { + return CosmosElement.TryCreateFromBuffer(buffer, out cosmosNull); + } public static bool TryParse( string json, - out CosmosNull cosmosNull) => CosmosElement.TryParse(json, out cosmosNull); + out CosmosNull cosmosNull) + { + return CosmosElement.TryParse(json, out cosmosNull); + } - public int CompareTo(CosmosNull other) => 0; + public int CompareTo(CosmosNull other) + { + return 0; + } public static new class Monadic { - public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.Monadic.CreateFromBuffer(buffer); + public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.Monadic.CreateFromBuffer(buffer); + } - public static TryCatch Parse(string json) => CosmosElement.Monadic.Parse(json); + public static TryCatch Parse(string json) + { + return CosmosElement.Monadic.Parse(json); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNumber.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNumber.cs index 863b2c4e1..46e839dfe 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNumber.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNumber.cs @@ -31,13 +31,25 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public abstract TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input); - public override void Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override void Accept(ICosmosElementVisitor cosmosElementVisitor) + { + cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) + { + return cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) + { + return cosmosElementVisitor.Visit(this, input); + } - public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosNumber cosmosNumber && this.Equals(cosmosNumber); + public override bool Equals(CosmosElement cosmosElement) + { + return cosmosElement is CosmosNumber cosmosNumber && this.Equals(cosmosNumber); + } public abstract bool Equals(CosmosNumber cosmosNumber); @@ -55,23 +67,41 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return this.Accept(CosmosNumberWithinTypeComparer.Singleton, other); } - public static new CosmosNumber CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.CreateFromBuffer(buffer); + public static new CosmosNumber CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.CreateFromBuffer(buffer); + } - public static new CosmosNumber Parse(string json) => CosmosElement.Parse(json); + public static new CosmosNumber Parse(string json) + { + return CosmosElement.Parse(json); + } public static bool TryCreateFromBuffer( ReadOnlyMemory buffer, - out CosmosNumber cosmosNumber) => CosmosElement.TryCreateFromBuffer(buffer, out cosmosNumber); + out CosmosNumber cosmosNumber) + { + return CosmosElement.TryCreateFromBuffer(buffer, out cosmosNumber); + } public static bool TryParse( string json, - out CosmosNumber cosmosNumber) => CosmosElement.TryParse(json, out cosmosNumber); + out CosmosNumber cosmosNumber) + { + return CosmosElement.TryParse(json, out cosmosNumber); + } public static new class Monadic { - public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.Monadic.CreateFromBuffer(buffer); + public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.Monadic.CreateFromBuffer(buffer); + } - public static TryCatch Parse(string json) => CosmosElement.Monadic.Parse(json); + public static TryCatch Parse(string json) + { + return CosmosElement.Monadic.Parse(json); + } } private sealed class CosmosNumberToTypeOrder : ICosmosNumberVisitor @@ -82,14 +112,45 @@ namespace Microsoft.Azure.Cosmos.CosmosElements { } - public int Visit(CosmosNumber64 cosmosNumber64) => 0; - public int Visit(CosmosInt8 cosmosInt8) => 1; - public int Visit(CosmosInt16 cosmosInt16) => 2; - public int Visit(CosmosInt32 cosmosInt32) => 3; - public int Visit(CosmosInt64 cosmosInt64) => 4; - public int Visit(CosmosUInt32 cosmosUInt32) => 5; - public int Visit(CosmosFloat32 cosmosFloat32) => 6; - public int Visit(CosmosFloat64 cosmosFloat64) => 7; + public int Visit(CosmosNumber64 cosmosNumber64) + { + return 0; + } + + public int Visit(CosmosInt8 cosmosInt8) + { + return 1; + } + + public int Visit(CosmosInt16 cosmosInt16) + { + return 2; + } + + public int Visit(CosmosInt32 cosmosInt32) + { + return 3; + } + + public int Visit(CosmosInt64 cosmosInt64) + { + return 4; + } + + public int Visit(CosmosUInt32 cosmosUInt32) + { + return 5; + } + + public int Visit(CosmosFloat32 cosmosFloat32) + { + return 6; + } + + public int Visit(CosmosFloat64 cosmosFloat64) + { + return 7; + } } private sealed class CosmosNumberWithinTypeComparer : ICosmosNumberVisitor @@ -100,14 +161,45 @@ namespace Microsoft.Azure.Cosmos.CosmosElements { } - public int Visit(CosmosNumber64 cosmosNumber64, CosmosNumber input) => cosmosNumber64.CompareTo((CosmosNumber64)input); - public int Visit(CosmosInt8 cosmosInt8, CosmosNumber input) => cosmosInt8.CompareTo((CosmosInt8)input); - public int Visit(CosmosInt16 cosmosInt16, CosmosNumber input) => cosmosInt16.CompareTo((CosmosInt16)input); - public int Visit(CosmosInt32 cosmosInt32, CosmosNumber input) => cosmosInt32.CompareTo((CosmosInt32)input); - public int Visit(CosmosInt64 cosmosInt64, CosmosNumber input) => cosmosInt64.CompareTo((CosmosInt64)input); - public int Visit(CosmosUInt32 cosmosUInt32, CosmosNumber input) => cosmosUInt32.CompareTo((CosmosUInt32)input); - public int Visit(CosmosFloat32 cosmosFloat32, CosmosNumber input) => cosmosFloat32.CompareTo((CosmosFloat32)input); - public int Visit(CosmosFloat64 cosmosFloat64, CosmosNumber input) => cosmosFloat64.CompareTo((CosmosFloat64)input); + public int Visit(CosmosNumber64 cosmosNumber64, CosmosNumber input) + { + return cosmosNumber64.CompareTo((CosmosNumber64)input); + } + + public int Visit(CosmosInt8 cosmosInt8, CosmosNumber input) + { + return cosmosInt8.CompareTo((CosmosInt8)input); + } + + public int Visit(CosmosInt16 cosmosInt16, CosmosNumber input) + { + return cosmosInt16.CompareTo((CosmosInt16)input); + } + + public int Visit(CosmosInt32 cosmosInt32, CosmosNumber input) + { + return cosmosInt32.CompareTo((CosmosInt32)input); + } + + public int Visit(CosmosInt64 cosmosInt64, CosmosNumber input) + { + return cosmosInt64.CompareTo((CosmosInt64)input); + } + + public int Visit(CosmosUInt32 cosmosUInt32, CosmosNumber input) + { + return cosmosUInt32.CompareTo((CosmosUInt32)input); + } + + public int Visit(CosmosFloat32 cosmosFloat32, CosmosNumber input) + { + return cosmosFloat32.CompareTo((CosmosFloat32)input); + } + + public int Visit(CosmosFloat64 cosmosFloat64, CosmosNumber input) + { + return cosmosFloat64.CompareTo((CosmosFloat64)input); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.EagerCosmosObject.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.EagerCosmosObject.cs index 6476b6556..114215c70 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.EagerCosmosObject.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.EagerCosmosObject.cs @@ -47,9 +47,15 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public override int Count => this.properties.Count; - public override bool ContainsKey(string key) => this.TryGetValue(key, out _); + public override bool ContainsKey(string key) + { + return this.TryGetValue(key, out _); + } - public override IEnumerator> GetEnumerator() => this.properties.GetEnumerator(); + public override IEnumerator> GetEnumerator() + { + return this.properties.GetEnumerator(); + } public override bool TryGetValue(string key, out CosmosElement value) { diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.LazyCosmosObject.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.LazyCosmosObject.cs index a0c279a6e..9c52ca42f 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.LazyCosmosObject.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.LazyCosmosObject.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Cosmos.CosmosElements using System; using System.Collections.Concurrent; using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.Azure.Cosmos.Json; @@ -69,20 +68,26 @@ namespace Microsoft.Azure.Cosmos.CosmosElements } } - public override bool ContainsKey(string key) => this.jsonNavigator.TryGetObjectProperty( - this.jsonNavigatorNode, - key, - out _); + public override bool ContainsKey(string key) + { + return this.jsonNavigator.TryGetObjectProperty( +this.jsonNavigatorNode, +key, +out _); + } - public override IEnumerator> GetEnumerator() => this - .jsonNavigator - .GetObjectProperties(this.jsonNavigatorNode) - .Select( - (objectProperty) => - new KeyValuePair( - this.jsonNavigator.GetStringValue(objectProperty.NameNode), - CosmosElement.Dispatch(this.jsonNavigator, objectProperty.ValueNode))) - .GetEnumerator(); + public override IEnumerator> GetEnumerator() + { + return this +.jsonNavigator +.GetObjectProperties(this.jsonNavigatorNode) +.Select( +(objectProperty) => +new KeyValuePair( +this.jsonNavigator.GetStringValue(objectProperty.NameNode), +CosmosElement.Dispatch(this.jsonNavigator, objectProperty.ValueNode))) +.GetEnumerator(); + } public override bool TryGetValue(string key, out CosmosElement value) { @@ -111,9 +116,15 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return false; } - public override void WriteTo(IJsonWriter jsonWriter) => this.jsonNavigator.WriteNode(this.jsonNavigatorNode, jsonWriter); + public override void WriteTo(IJsonWriter jsonWriter) + { + this.jsonNavigator.WriteNode(this.jsonNavigatorNode, jsonWriter); + } - public override IJsonReader CreateReader() => this.jsonNavigator.CreateReader(this.jsonNavigatorNode); + public override IJsonReader CreateReader() + { + return this.jsonNavigator.CreateReader(this.jsonNavigatorNode); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.cs index a63393e20..6bfa438e7 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.cs @@ -43,11 +43,20 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public abstract bool TryGetValue(string key, out CosmosElement value); - public override void Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override void Accept(ICosmosElementVisitor cosmosElementVisitor) + { + cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) + { + return cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) + { + return cosmosElementVisitor.Visit(this, input); + } public bool TryGetValue(string key, out TCosmosElement typedCosmosElement) where TCosmosElement : CosmosElement @@ -74,9 +83,15 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public abstract IEnumerator> GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } - public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosObject cosmosObject && this.Equals(cosmosObject); + public override bool Equals(CosmosElement cosmosElement) + { + return cosmosElement is CosmosObject cosmosObject && this.Equals(cosmosObject); + } public bool Equals(CosmosObject cosmosObject) { @@ -135,29 +150,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public static CosmosObject Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosObject(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosObject(jsonNavigator, jsonNavigatorNode); + } - public static CosmosObject Create(IReadOnlyDictionary dictionary) => new EagerCosmosObject(dictionary.ToList()); + public static CosmosObject Create(IReadOnlyDictionary dictionary) + { + return new EagerCosmosObject(dictionary.ToList()); + } - public static CosmosObject Create(IReadOnlyList> properties) => new EagerCosmosObject(properties); + public static CosmosObject Create(IReadOnlyList> properties) + { + return new EagerCosmosObject(properties); + } - public static new CosmosObject CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.CreateFromBuffer(buffer); + public static new CosmosObject CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.CreateFromBuffer(buffer); + } - public static new CosmosObject Parse(string json) => CosmosElement.Parse(json); + public static new CosmosObject Parse(string json) + { + return CosmosElement.Parse(json); + } public static bool TryCreateFromBuffer( ReadOnlyMemory buffer, - out CosmosObject cosmosObject) => CosmosElement.TryCreateFromBuffer(buffer, out cosmosObject); + out CosmosObject cosmosObject) + { + return CosmosElement.TryCreateFromBuffer(buffer, out cosmosObject); + } public static bool TryParse( string json, - out CosmosObject cosmosObject) => CosmosElement.TryParse(json, out cosmosObject); + out CosmosObject cosmosObject) + { + return CosmosElement.TryParse(json, out cosmosObject); + } public static new class Monadic { - public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.Monadic.CreateFromBuffer(buffer); + public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.Monadic.CreateFromBuffer(buffer); + } - public static TryCatch Parse(string json) => CosmosElement.Monadic.Parse(json); + public static TryCatch Parse(string json) + { + return CosmosElement.Monadic.Parse(json); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.EagerCosmosString.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.EagerCosmosString.cs index ae9417a2d..5ff0709dd 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.EagerCosmosString.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.EagerCosmosString.cs @@ -33,7 +33,10 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return false; } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteStringValue(this.Value); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteStringValue(this.Value); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.LazyCosmosString.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.LazyCosmosString.cs index deeeed9c4..e89a1800f 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.LazyCosmosString.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.LazyCosmosString.cs @@ -38,11 +38,17 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public override string Value => this.lazyString.Value; - public override bool TryGetBufferedValue(out Utf8Memory bufferedValue) => this.jsonNavigator.TryGetBufferedStringValue( - this.jsonNavigatorNode, - out bufferedValue); + public override bool TryGetBufferedValue(out Utf8Memory bufferedValue) + { + return this.jsonNavigator.TryGetBufferedStringValue( +this.jsonNavigatorNode, +out bufferedValue); + } - public override void WriteTo(IJsonWriter jsonWriter) => this.jsonNavigator.WriteNode(this.jsonNavigatorNode, jsonWriter); + public override void WriteTo(IJsonWriter jsonWriter) + { + this.jsonNavigator.WriteNode(this.jsonNavigatorNode, jsonWriter); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.cs index ac2087a4e..fda413b17 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosString.cs @@ -32,15 +32,30 @@ namespace Microsoft.Azure.Cosmos.CosmosElements public abstract bool TryGetBufferedValue(out Utf8Memory bufferedUtf8Value); - public override void Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override void Accept(ICosmosElementVisitor cosmosElementVisitor) + { + cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) => cosmosElementVisitor.Visit(this); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor) + { + return cosmosElementVisitor.Visit(this); + } - public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input); + public override TResult Accept(ICosmosElementVisitor cosmosElementVisitor, TArg input) + { + return cosmosElementVisitor.Visit(this, input); + } - public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosString cosmosString && this.Equals(cosmosString); + public override bool Equals(CosmosElement cosmosElement) + { + return cosmosElement is CosmosString cosmosString && this.Equals(cosmosString); + } - public bool Equals(CosmosString cosmosString) => this.Value == cosmosString.Value; + public bool Equals(CosmosString cosmosString) + { + return this.Value == cosmosString.Value; + } public override int GetHashCode() { @@ -50,31 +65,58 @@ namespace Microsoft.Azure.Cosmos.CosmosElements return (int)hash; } - public int CompareTo(CosmosString cosmosString) => string.CompareOrdinal(this.Value, cosmosString.Value); + public int CompareTo(CosmosString cosmosString) + { + return string.CompareOrdinal(this.Value, cosmosString.Value); + } public static CosmosString Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosString(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosString(jsonNavigator, jsonNavigatorNode); + } - public static CosmosString Create(string value) => value.Length == 0 ? EagerCosmosString.Empty : new EagerCosmosString(value); + public static CosmosString Create(string value) + { + return value.Length == 0 ? EagerCosmosString.Empty : new EagerCosmosString(value); + } - public static new CosmosString CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.CreateFromBuffer(buffer); + public static new CosmosString CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.CreateFromBuffer(buffer); + } - public static new CosmosString Parse(string json) => CosmosElement.Parse(json); + public static new CosmosString Parse(string json) + { + return CosmosElement.Parse(json); + } public static bool TryCreateFromBuffer( ReadOnlyMemory buffer, - out CosmosString cosmosString) => CosmosElement.TryCreateFromBuffer(buffer, out cosmosString); + out CosmosString cosmosString) + { + return CosmosElement.TryCreateFromBuffer(buffer, out cosmosString); + } public static bool TryParse( string json, - out CosmosString cosmosString) => CosmosElement.TryParse(json, out cosmosString); + out CosmosString cosmosString) + { + return CosmosElement.TryParse(json, out cosmosString); + } public static new class Monadic { - public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) => CosmosElement.Monadic.CreateFromBuffer(buffer); + public static TryCatch CreateFromBuffer(ReadOnlyMemory buffer) + { + return CosmosElement.Monadic.CreateFromBuffer(buffer); + } - public static TryCatch Parse(string json) => CosmosElement.Monadic.Parse(json); + public static TryCatch Parse(string json) + { + return CosmosElement.Monadic.Parse(json); + } } } #if INTERNAL diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat32.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat32.cs index ff26e622b..22e1a7769 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat32.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat32.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract float GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosFloat32 cosmosFloat32 && this.Equals(cosmosFloat32); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosFloat32 cosmosFloat32 && this.Equals(cosmosFloat32); + } - public bool Equals(CosmosFloat32 cosmosFloat32) => this.GetValue() == cosmosFloat32.GetValue(); + public bool Equals(CosmosFloat32 cosmosFloat32) + { + return this.GetValue() == cosmosFloat32.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(this.GetValue(), 495253708); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(this.GetValue(), 495253708); + } - public int CompareTo(CosmosFloat32 cosmosFloat32) => this.GetValue().CompareTo(cosmosFloat32.GetValue()); + public int CompareTo(CosmosFloat32 cosmosFloat32) + { + return this.GetValue().CompareTo(cosmosFloat32.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteFloat32Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteFloat32Value(this.GetValue()); + } public static CosmosFloat32 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosFloat32(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosFloat32(jsonNavigator, jsonNavigatorNode); + } - public static CosmosFloat32 Create(float number) => new EagerCosmosFloat32(number); + public static CosmosFloat32 Create(float number) + { + return new EagerCosmosFloat32(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat64.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat64.cs index 21f87144f..e25224ca3 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat64.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosFloat64.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract double GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosFloat64 cosmosFloat64 && this.Equals(cosmosFloat64); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosFloat64 cosmosFloat64 && this.Equals(cosmosFloat64); + } - public bool Equals(CosmosFloat64 cosmosFloat64) => this.GetValue() == cosmosFloat64.GetValue(); + public bool Equals(CosmosFloat64 cosmosFloat64) + { + return this.GetValue() == cosmosFloat64.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(this.GetValue(), 470975939); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(this.GetValue(), 470975939); + } - public int CompareTo(CosmosFloat64 cosmosFloat64) => this.GetValue().CompareTo(cosmosFloat64.GetValue()); + public int CompareTo(CosmosFloat64 cosmosFloat64) + { + return this.GetValue().CompareTo(cosmosFloat64.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteFloat64Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteFloat64Value(this.GetValue()); + } public static CosmosFloat64 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosFloat64(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosFloat64(jsonNavigator, jsonNavigatorNode); + } - public static CosmosFloat64 Create(double number) => new EagerCosmosFloat64(number); + public static CosmosFloat64 Create(double number) + { + return new EagerCosmosFloat64(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt16.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt16.cs index 100865e43..4b2a19465 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt16.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt16.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract short GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosInt16 cosmosInt16 && this.Equals(cosmosInt16); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosInt16 cosmosInt16 && this.Equals(cosmosInt16); + } - public bool Equals(CosmosInt16 cosmosInt16) => this.GetValue() == cosmosInt16.GetValue(); + public bool Equals(CosmosInt16 cosmosInt16) + { + return this.GetValue() == cosmosInt16.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(this.GetValue(), 1176550641); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(this.GetValue(), 1176550641); + } - public int CompareTo(CosmosInt16 cosmosInt16) => this.GetValue().CompareTo(cosmosInt16.GetValue()); + public int CompareTo(CosmosInt16 cosmosInt16) + { + return this.GetValue().CompareTo(cosmosInt16.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteInt16Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteInt16Value(this.GetValue()); + } public static CosmosInt16 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosInt16(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosInt16(jsonNavigator, jsonNavigatorNode); + } - public static CosmosInt16 Create(short number) => new EagerCosmosInt16(number); + public static CosmosInt16 Create(short number) + { + return new EagerCosmosInt16(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt32.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt32.cs index 87645ca67..616b43ba6 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt32.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt32.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract int GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosInt32 cosmosInt32 && this.Equals(cosmosInt32); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosInt32 cosmosInt32 && this.Equals(cosmosInt32); + } - public bool Equals(CosmosInt32 cosmosInt32) => this.GetValue() == cosmosInt32.GetValue(); + public bool Equals(CosmosInt32 cosmosInt32) + { + return this.GetValue() == cosmosInt32.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(this.GetValue(), 1791401667); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(this.GetValue(), 1791401667); + } - public int CompareTo(CosmosInt32 cosmosInt32) => this.GetValue().CompareTo(cosmosInt32.GetValue()); + public int CompareTo(CosmosInt32 cosmosInt32) + { + return this.GetValue().CompareTo(cosmosInt32.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteInt32Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteInt32Value(this.GetValue()); + } public static CosmosInt32 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosInt32(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosInt32(jsonNavigator, jsonNavigatorNode); + } - public static CosmosInt32 Create(int number) => new EagerCosmosInt32(number); + public static CosmosInt32 Create(int number) + { + return new EagerCosmosInt32(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt64.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt64.cs index 34899921b..9cdd2e4c1 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt64.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt64.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract long GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosInt64 cosmosInt64 && this.Equals(cosmosInt64); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosInt64 cosmosInt64 && this.Equals(cosmosInt64); + } - public bool Equals(CosmosInt64 cosmosInt64) => this.GetValue() == cosmosInt64.GetValue(); + public bool Equals(CosmosInt64 cosmosInt64) + { + return this.GetValue() == cosmosInt64.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(this.GetValue(), 2562566505); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(this.GetValue(), 2562566505); + } - public int CompareTo(CosmosInt64 cosmosInt64) => this.GetValue().CompareTo(cosmosInt64.GetValue()); + public int CompareTo(CosmosInt64 cosmosInt64) + { + return this.GetValue().CompareTo(cosmosInt64.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteInt64Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteInt64Value(this.GetValue()); + } public static CosmosInt64 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosInt64(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosInt64(jsonNavigator, jsonNavigatorNode); + } - public static CosmosInt64 Create(long number) => new EagerCosmosInt64(number); + public static CosmosInt64 Create(long number) + { + return new EagerCosmosInt64(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt8.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt8.cs index 4e8d1ab33..befe9c681 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt8.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosInt8.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract sbyte GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosInt8 cosmosInt8 && this.Equals(cosmosInt8); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosInt8 cosmosInt8 && this.Equals(cosmosInt8); + } - public bool Equals(CosmosInt8 cosmosInt8) => this.GetValue() == cosmosInt8.GetValue(); + public bool Equals(CosmosInt8 cosmosInt8) + { + return this.GetValue() == cosmosInt8.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(this.GetValue(), 1301790982); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(this.GetValue(), 1301790982); + } - public int CompareTo(CosmosInt8 cosmosInt8) => this.GetValue().CompareTo(cosmosInt8.GetValue()); + public int CompareTo(CosmosInt8 cosmosInt8) + { + return this.GetValue().CompareTo(cosmosInt8.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteInt8Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteInt8Value(this.GetValue()); + } public static CosmosInt8 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosInt8(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosInt8(jsonNavigator, jsonNavigatorNode); + } - public static CosmosInt8 Create(sbyte number) => new EagerCosmosInt8(number); + public static CosmosInt8 Create(sbyte number) + { + return new EagerCosmosInt8(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosNumber64.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosNumber64.cs index 0050a86c4..2cb027355 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosNumber64.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosNumber64.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract Number64 GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosNumber64 cosmosNumber64 && this.Equals(cosmosNumber64); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosNumber64 cosmosNumber64 && this.Equals(cosmosNumber64); + } - public bool Equals(CosmosNumber64 cosmosNumber64) => this.GetValue() == cosmosNumber64.GetValue(); + public bool Equals(CosmosNumber64 cosmosNumber64) + { + return this.GetValue() == cosmosNumber64.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(Number64.ToDoubleEx(this.GetValue()), 1943952435); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(Number64.ToDoubleEx(this.GetValue()), 1943952435); + } - public int CompareTo(CosmosNumber64 cosmosNumber64) => this.GetValue().CompareTo(cosmosNumber64.GetValue()); + public int CompareTo(CosmosNumber64 cosmosNumber64) + { + return this.GetValue().CompareTo(cosmosNumber64.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteNumber64Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteNumber64Value(this.GetValue()); + } public static CosmosNumber64 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosNumber64(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosNumber64(jsonNavigator, jsonNavigatorNode); + } - public static CosmosNumber64 Create(Number64 number) => new EagerCosmosNumber64(number); + public static CosmosNumber64 Create(Number64 number) + { + return new EagerCosmosNumber64(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosUInt32.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosUInt32.cs index 95b46eec9..61b35e600 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosUInt32.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosElements/Numbers/CosmosUInt32.cs @@ -30,26 +30,56 @@ namespace Microsoft.Azure.Cosmos.CosmosElements.Numbers public abstract uint GetValue(); - public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override void Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + cosmosNumberVisitor.Visit(this); + } - public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) => cosmosNumberVisitor.Visit(this); + public override TResult Accept(ICosmosNumberVisitor cosmosNumberVisitor) + { + return cosmosNumberVisitor.Visit(this); + } - public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) => cosmosNumberVisitor.Visit(this, input); + public override TOutput Accept(ICosmosNumberVisitor cosmosNumberVisitor, TArg input) + { + return cosmosNumberVisitor.Visit(this, input); + } - public override bool Equals(CosmosNumber cosmosNumber) => cosmosNumber is CosmosUInt32 cosmosUInt32 && this.Equals(cosmosUInt32); + public override bool Equals(CosmosNumber cosmosNumber) + { + return cosmosNumber is CosmosUInt32 cosmosUInt32 && this.Equals(cosmosUInt32); + } - public bool Equals(CosmosUInt32 cosmosUInt32) => this.GetValue() == cosmosUInt32.GetValue(); + public bool Equals(CosmosUInt32 cosmosUInt32) + { + return this.GetValue() == cosmosUInt32.GetValue(); + } - public override int GetHashCode() => (int)MurmurHash3.Hash32(this.GetValue(), 3771427877); + public override int GetHashCode() + { + return (int)MurmurHash3.Hash32(this.GetValue(), 3771427877); + } - public int CompareTo(CosmosUInt32 cosmosUInt32) => this.GetValue().CompareTo(cosmosUInt32.GetValue()); + public int CompareTo(CosmosUInt32 cosmosUInt32) + { + return this.GetValue().CompareTo(cosmosUInt32.GetValue()); + } - public override void WriteTo(IJsonWriter jsonWriter) => jsonWriter.WriteUInt32Value(this.GetValue()); + public override void WriteTo(IJsonWriter jsonWriter) + { + jsonWriter.WriteUInt32Value(this.GetValue()); + } public static CosmosUInt32 Create( IJsonNavigator jsonNavigator, - IJsonNavigatorNode jsonNavigatorNode) => new LazyCosmosUInt32(jsonNavigator, jsonNavigatorNode); + IJsonNavigatorNode jsonNavigatorNode) + { + return new LazyCosmosUInt32(jsonNavigator, jsonNavigatorNode); + } - public static CosmosUInt32 Create(uint number) => new EagerCosmosUInt32(number); + public static CosmosUInt32 Create(uint number) + { + return new EagerCosmosUInt32(number); + } } } diff --git a/Microsoft.Azure.Cosmos/src/CosmosIndexJsonConverter.cs b/Microsoft.Azure.Cosmos/src/CosmosIndexJsonConverter.cs index 466782e76..2af73beda 100644 --- a/Microsoft.Azure.Cosmos/src/CosmosIndexJsonConverter.cs +++ b/Microsoft.Azure.Cosmos/src/CosmosIndexJsonConverter.cs @@ -73,13 +73,7 @@ namespace Microsoft.Azure.Cosmos } } - public override bool CanWrite - { - get - { - return false; - } - } + public override bool CanWrite => false; public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { diff --git a/Microsoft.Azure.Cosmos/src/Diagnostics/CosmosClientSideRequestStatistics.cs b/Microsoft.Azure.Cosmos/src/Diagnostics/CosmosClientSideRequestStatistics.cs index fe92b7125..7ec66578d 100644 --- a/Microsoft.Azure.Cosmos/src/Diagnostics/CosmosClientSideRequestStatistics.cs +++ b/Microsoft.Azure.Cosmos/src/Diagnostics/CosmosClientSideRequestStatistics.cs @@ -7,12 +7,9 @@ namespace Microsoft.Azure.Cosmos using System; using System.Collections.Generic; using System.Diagnostics; - using System.Globalization; - using System.IO; using System.Text; using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Documents; - using Newtonsoft.Json; internal sealed class CosmosClientSideRequestStatistics : CosmosDiagnosticsInternal, IClientSideRequestStatistics { @@ -44,7 +41,7 @@ namespace Microsoft.Azure.Cosmos private Dictionary EndpointToAddressResolutionStatistics { get; } - private Dictionary RecordRequestHashCodeToStartTime = new Dictionary(); + private readonly Dictionary RecordRequestHashCodeToStartTime = new Dictionary(); public List ContactedReplicas { get; set; } diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index e45a7fd01..cb7ddc3c8 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -738,7 +738,7 @@ namespace Microsoft.Azure.Cosmos /// ]]> /// /// - public Task OpenAsync(CancellationToken cancellationToken = default(CancellationToken)) + public Task OpenAsync(CancellationToken cancellationToken = default) { return TaskHelper.InlineIfPossibleAsync(() => this.OpenPrivateInlineAsync(cancellationToken), null, cancellationToken); } @@ -1901,7 +1901,7 @@ namespace Microsoft.Azure.Cosmos /// public Task> CreateDocumentAsync(string documentsFeedOrDatabaseLink, object document, Documents.Client.RequestOptions options = null, bool disableAutomaticIdGeneration = false, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { // This call is to just run CreateDocumentInlineAsync in a SynchronizationContext aware environment return TaskHelper.InlineIfPossible(() => this.CreateDocumentInlineAsync(documentsFeedOrDatabaseLink, document, options, disableAutomaticIdGeneration, cancellationToken), null, cancellationToken); @@ -2798,7 +2798,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// - public Task> DeleteDocumentAsync(string documentLink, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> DeleteDocumentAsync(string documentLink, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default) { IDocumentClientRetryPolicy retryPolicyInstance = this.ResetSessionTokenRetryPolicy.GetRequestPolicy(); return TaskHelper.InlineIfPossible(() => this.DeleteDocumentPrivateAsync(documentLink, options, retryPolicyInstance, cancellationToken), retryPolicyInstance, cancellationToken); @@ -3273,7 +3273,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// - public Task> ReplaceDocumentAsync(string documentLink, object document, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> ReplaceDocumentAsync(string documentLink, object document, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default) { // This call is to just run ReplaceDocumentInlineAsync in a SynchronizationContext aware environment return TaskHelper.InlineIfPossible(() => this.ReplaceDocumentInlineAsync(documentLink, document, options, cancellationToken), null, cancellationToken); @@ -3348,7 +3348,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// - public Task> ReplaceDocumentAsync(Document document, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> ReplaceDocumentAsync(Document document, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default) { IDocumentClientRetryPolicy retryPolicyInstance = this.ResetSessionTokenRetryPolicy.GetRequestPolicy(); return TaskHelper.InlineIfPossible(() => this.ReplaceDocumentPrivateAsync( @@ -3871,7 +3871,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// - public Task> ReadDocumentAsync(string documentLink, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> ReadDocumentAsync(string documentLink, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default) { IDocumentClientRetryPolicy retryPolicyInstance = this.ResetSessionTokenRetryPolicy.GetRequestPolicy(); return TaskHelper.InlineIfPossible( @@ -3953,7 +3953,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// - public Task> ReadDocumentAsync(string documentLink, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> ReadDocumentAsync(string documentLink, Documents.Client.RequestOptions options = null, CancellationToken cancellationToken = default) { IDocumentClientRetryPolicy retryPolicyInstance = this.ResetSessionTokenRetryPolicy.GetRequestPolicy(); return TaskHelper.InlineIfPossible( @@ -5151,7 +5151,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// - public Task> ReadDocumentFeedAsync(string documentsLink, FeedOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> ReadDocumentFeedAsync(string documentsLink, FeedOptions options = null, CancellationToken cancellationToken = default) { return TaskHelper.InlineIfPossible(() => this.ReadDocumentFeedInlineAsync(documentsLink, options, cancellationToken), null, cancellationToken); } @@ -5526,7 +5526,7 @@ namespace Microsoft.Azure.Cosmos /// public Task> ExecuteStoredProcedureAsync(string storedProcedureLink, params dynamic[] procedureParams) { - return this.ExecuteStoredProcedureAsync(storedProcedureLink, null, default(CancellationToken), procedureParams); + return this.ExecuteStoredProcedureAsync(storedProcedureLink, null, default, procedureParams); } /// @@ -5565,7 +5565,7 @@ namespace Microsoft.Azure.Cosmos storedProcedureLink, options, retryPolicyInstance, - default(CancellationToken), + default, procedureParams), retryPolicyInstance); } @@ -5843,7 +5843,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// - public Task> UpsertDocumentAsync(string documentsFeedOrDatabaseLink, object document, Documents.Client.RequestOptions options = null, bool disableAutomaticIdGeneration = false, CancellationToken cancellationToken = default(CancellationToken)) + public Task> UpsertDocumentAsync(string documentsFeedOrDatabaseLink, object document, Documents.Client.RequestOptions options = null, bool disableAutomaticIdGeneration = false, CancellationToken cancellationToken = default) { // This call is to just run UpsertDocumentInlineAsync in a SynchronizationContext aware environment return TaskHelper.InlineIfPossible(() => this.UpsertDocumentInlineAsync(documentsFeedOrDatabaseLink, document, options, disableAutomaticIdGeneration, cancellationToken), null, cancellationToken); @@ -6543,7 +6543,7 @@ namespace Microsoft.Azure.Cosmos internal Task CreateAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6556,7 +6556,7 @@ namespace Microsoft.Azure.Cosmos internal Task UpdateAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6569,7 +6569,7 @@ namespace Microsoft.Azure.Cosmos internal Task ReadAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6582,7 +6582,7 @@ namespace Microsoft.Azure.Cosmos internal Task ReadFeedAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6595,7 +6595,7 @@ namespace Microsoft.Azure.Cosmos internal Task DeleteAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6608,7 +6608,7 @@ namespace Microsoft.Azure.Cosmos internal Task ExecuteProcedureAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6621,7 +6621,7 @@ namespace Microsoft.Azure.Cosmos internal Task ExecuteQueryAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6634,7 +6634,7 @@ namespace Microsoft.Azure.Cosmos internal Task UpsertAsync( DocumentServiceRequest request, IDocumentClientRetryPolicy retryPolicy, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (request == null) { @@ -6671,7 +6671,7 @@ namespace Microsoft.Azure.Cosmos return this.GetDatabaseAccountPrivateAsync(serviceEndpoint, cancellationToken); } - private async Task GetDatabaseAccountPrivateAsync(Uri serviceEndpoint, CancellationToken cancellationToken = default(CancellationToken)) + private async Task GetDatabaseAccountPrivateAsync(Uri serviceEndpoint, CancellationToken cancellationToken = default) { await this.EnsureValidClientAsync(); GatewayStoreModel gatewayModel = this.GatewayStoreModel as GatewayStoreModel; diff --git a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRange.cs b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRange.cs index 8ef5a5ea8..89a77edc1 100644 --- a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRange.cs +++ b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRange.cs @@ -44,6 +44,9 @@ namespace Microsoft.Azure.Cosmos /// /// The partition key value to create a feed range from. /// The feed range that spans the partition. - public static FeedRange FromPartitionKey(PartitionKey partitionKey) => new FeedRangePartitionKey(partitionKey); + public static FeedRange FromPartitionKey(PartitionKey partitionKey) + { + return new FeedRangePartitionKey(partitionKey); + } } } diff --git a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeEpk.cs b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeEpk.cs index c6aab85d2..a9d9d38d3 100644 --- a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeEpk.cs +++ b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeEpk.cs @@ -32,7 +32,10 @@ namespace Microsoft.Azure.Cosmos public override Task>> GetEffectiveRangesAsync( IRoutingMapProvider routingMapProvider, string containerRid, - Documents.PartitionKeyDefinition partitionKeyDefinition) => Task.FromResult(new List>() { this.Range }); + Documents.PartitionKeyDefinition partitionKeyDefinition) + { + return Task.FromResult(new List>() { this.Range }); + } public override async Task> GetPartitionKeyRangesAsync( IRoutingMapProvider routingMapProvider, @@ -44,12 +47,21 @@ namespace Microsoft.Azure.Cosmos return partitionKeyRanges.Select(partitionKeyRange => partitionKeyRange.Id); } - public override void Accept(IFeedRangeVisitor visitor) => visitor.Visit(this); + public override void Accept(IFeedRangeVisitor visitor) + { + visitor.Visit(this); + } public override Task AcceptAsync( IFeedRangeAsyncVisitor visitor, - CancellationToken cancellationToken = default) => visitor.VisitAsync(this, cancellationToken); + CancellationToken cancellationToken = default) + { + return visitor.VisitAsync(this, cancellationToken); + } - public override string ToString() => this.Range.ToString(); + public override string ToString() + { + return this.Range.ToString(); + } } } diff --git a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeInternal.cs b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeInternal.cs index b38f3265e..54c5d941d 100644 --- a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeInternal.cs +++ b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangeInternal.cs @@ -31,7 +31,10 @@ namespace Microsoft.Azure.Cosmos public abstract override string ToString(); - public override string ToJsonString() => JsonConvert.SerializeObject(this); + public override string ToJsonString() + { + return JsonConvert.SerializeObject(this); + } public static bool TryParse( string jsonString, diff --git a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKey.cs b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKey.cs index 000b343bc..a1b3f7a58 100644 --- a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKey.cs +++ b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKey.cs @@ -24,12 +24,15 @@ namespace Microsoft.Azure.Cosmos public override Task>> GetEffectiveRangesAsync( IRoutingMapProvider routingMapProvider, string containerRid, - Documents.PartitionKeyDefinition partitionKeyDefinition) => Task.FromResult( - new List> - { + Documents.PartitionKeyDefinition partitionKeyDefinition) + { + return Task.FromResult( +new List> +{ Documents.Routing.Range.GetPointRange( this.PartitionKey.InternalKey.GetEffectivePartitionKeyString(partitionKeyDefinition)) - }); +}); + } public override async Task> GetPartitionKeyRangesAsync( IRoutingMapProvider routingMapProvider, @@ -42,12 +45,21 @@ namespace Microsoft.Azure.Cosmos return new List() { range.Id }; } - public override void Accept(IFeedRangeVisitor visitor) => visitor.Visit(this); + public override void Accept(IFeedRangeVisitor visitor) + { + visitor.Visit(this); + } public override Task AcceptAsync( IFeedRangeAsyncVisitor visitor, - CancellationToken cancellationToken = default) => visitor.VisitAsync(this, cancellationToken); + CancellationToken cancellationToken = default) + { + return visitor.VisitAsync(this, cancellationToken); + } - public override string ToString() => this.PartitionKey.InternalKey.ToJsonString(); + public override string ToString() + { + return this.PartitionKey.InternalKey.ToJsonString(); + } } } diff --git a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKeyRange.cs b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKeyRange.cs index c6c0b50cd..f96f26acd 100644 --- a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKeyRange.cs +++ b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKeyRange.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System; using System.Collections.Generic; using System.Net; using System.Threading; @@ -74,12 +73,21 @@ namespace Microsoft.Azure.Cosmos return Task.FromResult(partitionKeyRanges); } - public override void Accept(IFeedRangeVisitor visitor) => visitor.Visit(this); + public override void Accept(IFeedRangeVisitor visitor) + { + visitor.Visit(this); + } public override Task AcceptAsync( IFeedRangeAsyncVisitor visitor, - CancellationToken cancellationToken = default) => visitor.VisitAsync(this, cancellationToken); + CancellationToken cancellationToken = default) + { + return visitor.VisitAsync(this, cancellationToken); + } - public override string ToString() => this.PartitionKeyRangeId; + public override string ToString() + { + return this.PartitionKeyRangeId; + } } } diff --git a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/IFeedRangeContinuationVisitor.cs b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/IFeedRangeContinuationVisitor.cs index 93fcceb09..c817d1390 100644 --- a/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/IFeedRangeContinuationVisitor.cs +++ b/Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/IFeedRangeContinuationVisitor.cs @@ -4,10 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System; - using System.Collections.Generic; - using System.Text; - internal interface IFeedRangeContinuationVisitor { public void Visit(FeedRangeCompositeContinuation feedRangeCompositeContinuation); diff --git a/Microsoft.Azure.Cosmos/src/Fluent/CosmosClientBuilder.cs b/Microsoft.Azure.Cosmos/src/Fluent/CosmosClientBuilder.cs index 90bf23739..ccf3c18e1 100644 --- a/Microsoft.Azure.Cosmos/src/Fluent/CosmosClientBuilder.cs +++ b/Microsoft.Azure.Cosmos/src/Fluent/CosmosClientBuilder.cs @@ -146,7 +146,7 @@ namespace Microsoft.Azure.Cosmos.Fluent this.clientOptions.ApplicationRegion = applicationRegion; return this; } - + /// /// Set the preferred regions for geo-replicated database accounts in the Azure Cosmos DB service. /// diff --git a/Microsoft.Azure.Cosmos/src/Fluent/Settings/ContainerDefinition.cs b/Microsoft.Azure.Cosmos/src/Fluent/Settings/ContainerDefinition.cs index c25af4b55..a1141fc3f 100644 --- a/Microsoft.Azure.Cosmos/src/Fluent/Settings/ContainerDefinition.cs +++ b/Microsoft.Azure.Cosmos/src/Fluent/Settings/ContainerDefinition.cs @@ -13,7 +13,7 @@ namespace Microsoft.Azure.Cosmos.Fluent where T : ContainerDefinition { private readonly string containerName; - private string partitionKeyPath; + private readonly string partitionKeyPath; private int? defaultTimeToLive; private IndexingPolicy indexingPolicy; private string timeToLivePropertyPath; diff --git a/Microsoft.Azure.Cosmos/src/GatewayStoreClient.cs b/Microsoft.Azure.Cosmos/src/GatewayStoreClient.cs index 0fe24d6de..008b619f7 100644 --- a/Microsoft.Azure.Cosmos/src/GatewayStoreClient.cs +++ b/Microsoft.Azure.Cosmos/src/GatewayStoreClient.cs @@ -65,7 +65,7 @@ namespace Microsoft.Azure.Cosmos HttpTransportClient.GetResourceFeedUri(resourceOperation.resourceType, baseAddress, request) : HttpTransportClient.GetResourceEntryUri(resourceOperation.resourceType, baseAddress, request); - using (HttpResponseMessage responseMessage = await this.InvokeClientAsync(request, resourceOperation.resourceType, physicalAddress, default(CancellationToken))) + using (HttpResponseMessage responseMessage = await this.InvokeClientAsync(request, resourceOperation.resourceType, physicalAddress, default)) { return await HttpTransportClient.ProcessHttpResponse(request.ResourceAddress, string.Empty, responseMessage, physicalAddress, request); } @@ -75,7 +75,7 @@ namespace Microsoft.Azure.Cosmos internal Task SendHttpAsync( Func> requestMessage, ResourceType resourceType, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.httpClient.SendHttpAsync( createRequestMessageAsync: requestMessage, diff --git a/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs b/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs index 0d2f959aa..956d1f190 100644 --- a/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs +++ b/Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs @@ -47,7 +47,7 @@ namespace Microsoft.Azure.Cosmos serializerSettings); } - public virtual async Task ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken = default(CancellationToken)) + public virtual async Task ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken = default) { GatewayStoreModel.ApplySessionToken( request, @@ -76,7 +76,7 @@ namespace Microsoft.Azure.Cosmos return response; } - public virtual async Task GetDatabaseAccountAsync(Func> requestMessage, CancellationToken cancellationToken = default(CancellationToken)) + public virtual async Task GetDatabaseAccountAsync(Func> requestMessage, CancellationToken cancellationToken = default) { AccountProperties databaseAccount = null; diff --git a/Microsoft.Azure.Cosmos/src/Handler/PartitionKeyRangeHandler.cs b/Microsoft.Azure.Cosmos/src/Handler/PartitionKeyRangeHandler.cs index 4403c8c18..3c4628c6f 100644 --- a/Microsoft.Azure.Cosmos/src/Handler/PartitionKeyRangeHandler.cs +++ b/Microsoft.Azure.Cosmos/src/Handler/PartitionKeyRangeHandler.cs @@ -11,7 +11,6 @@ namespace Microsoft.Azure.Cosmos.Handlers using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Common; - using Microsoft.Azure.Cosmos.Query; using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Routing; using Microsoft.Azure.Documents; @@ -29,7 +28,7 @@ namespace Microsoft.Azure.Cosmos.Handlers internal class PartitionKeyRangeHandler : RequestHandler { private readonly CosmosClient client; - private PartitionRoutingHelper partitionRoutingHelper; + private readonly PartitionRoutingHelper partitionRoutingHelper; public PartitionKeyRangeHandler(CosmosClient client, PartitionRoutingHelper partitionRoutingHelper = null) { if (client == null) diff --git a/Microsoft.Azure.Cosmos/src/Handler/RequestHandler.cs b/Microsoft.Azure.Cosmos/src/Handler/RequestHandler.cs index 54a8347fe..4e6baa370 100644 --- a/Microsoft.Azure.Cosmos/src/Handler/RequestHandler.cs +++ b/Microsoft.Azure.Cosmos/src/Handler/RequestHandler.cs @@ -5,10 +5,8 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Diagnostics; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos.Diagnostics; /// /// Abstraction which allows defining of custom message handlers. diff --git a/Microsoft.Azure.Cosmos/src/Handler/RequestInvokerHandler.cs b/Microsoft.Azure.Cosmos/src/Handler/RequestInvokerHandler.cs index 83d590595..50dc19e7b 100644 --- a/Microsoft.Azure.Cosmos/src/Handler/RequestInvokerHandler.cs +++ b/Microsoft.Azure.Cosmos/src/Handler/RequestInvokerHandler.cs @@ -11,7 +11,6 @@ namespace Microsoft.Azure.Cosmos.Handlers using System.Net.Http; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Routing; @@ -20,11 +19,11 @@ namespace Microsoft.Azure.Cosmos.Handlers /// internal class RequestInvokerHandler : RequestHandler { - private static (bool, ResponseMessage) clientIsValid = (false, null); private readonly CosmosClient client; - private Cosmos.ConsistencyLevel? AccountConsistencyLevel = null; - private Cosmos.ConsistencyLevel? RequestedClientConsistencyLevel; + private readonly Cosmos.ConsistencyLevel? RequestedClientConsistencyLevel; private static readonly HttpMethod httpPatchMethod = new HttpMethod(HttpConstants.HttpMethods.Patch); + private Cosmos.ConsistencyLevel? AccountConsistencyLevel = null; + private static (bool, ResponseMessage) clientIsValid = (false, null); public RequestInvokerHandler( CosmosClient client, diff --git a/Microsoft.Azure.Cosmos/src/Handler/ResponseMessage.cs b/Microsoft.Azure.Cosmos/src/Handler/ResponseMessage.cs index 40d7ab16c..3c7c05592 100644 --- a/Microsoft.Azure.Cosmos/src/Handler/ResponseMessage.cs +++ b/Microsoft.Azure.Cosmos/src/Handler/ResponseMessage.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Cosmos using System.Diagnostics; using System.IO; using System.Net; - using System.Text; using Microsoft.Azure.Cosmos.Resource.CosmosExceptions; using Microsoft.Azure.Documents; diff --git a/Microsoft.Azure.Cosmos/src/Handler/TransportHandler.cs b/Microsoft.Azure.Cosmos/src/Handler/TransportHandler.cs index 6467ff812..eaef0529d 100644 --- a/Microsoft.Azure.Cosmos/src/Handler/TransportHandler.cs +++ b/Microsoft.Azure.Cosmos/src/Handler/TransportHandler.cs @@ -9,7 +9,6 @@ namespace Microsoft.Azure.Cosmos.Handlers using System.Linq; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Documents; //TODO: write unit test for this handler diff --git a/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs b/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs index 0cf14be2e..9930c1283 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/CosmosMessageHeadersInternal.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Cosmos using System.Collections.Specialized; using System.Globalization; using System.Linq; - using System.Reflection; using Microsoft.Azure.Documents.Collections; /// @@ -62,18 +61,14 @@ namespace Microsoft.Azure.Cosmos { get { - string value; - if (!this.TryGetValue(headerName, out value)) + if (!this.TryGetValue(headerName, out string value)) { return null; } return value; } - set - { - this.Set(headerName, value); - } + set => this.Set(headerName, value); } public void Set(string key, string value) @@ -180,7 +175,7 @@ namespace Microsoft.Azure.Cosmos if (string.IsNullOrEmpty(value)) { - return default(T); + return default; } if (typeof(T) == typeof(double)) diff --git a/Microsoft.Azure.Cosmos/src/Headers/CosmosQueryResponseMessageHeaders.cs b/Microsoft.Azure.Cosmos/src/Headers/CosmosQueryResponseMessageHeaders.cs index b93ba0166..0fca37356 100644 --- a/Microsoft.Azure.Cosmos/src/Headers/CosmosQueryResponseMessageHeaders.cs +++ b/Microsoft.Azure.Cosmos/src/Headers/CosmosQueryResponseMessageHeaders.cs @@ -38,10 +38,7 @@ namespace Microsoft.Azure.Cosmos return base.ContinuationToken; } - internal set - { - throw new InvalidOperationException("To prevent the different aggregate context from impacting each other only allow updating the continuation token via clone method."); - } + internal set => throw new InvalidOperationException("To prevent the different aggregate context from impacting each other only allow updating the continuation token via clone method."); } internal virtual string ContainerRid { get; } diff --git a/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs b/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs index e834f9475..dfd221149 100644 --- a/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs +++ b/Microsoft.Azure.Cosmos/src/HttpClient/CosmosHttpClientCore.cs @@ -10,10 +10,8 @@ namespace Microsoft.Azure.Cosmos using System.Net; using System.Net.Http; using System.Net.Http.Headers; - using System.Text; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos.Resource.CosmosExceptions; using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Collections; @@ -245,7 +243,11 @@ namespace Microsoft.Azure.Cosmos } }; - HttpRequestMessage GetHttpRequestMessage() => requestMessage; + HttpRequestMessage GetHttpRequestMessage() + { + return requestMessage; + } + return BackoffRetryUtility.ExecuteAsync( callbackMethod: funcDelegate, retryPolicy: new TransientHttpClientRetryPolicy( diff --git a/Microsoft.Azure.Cosmos/src/ICosmosAuthorizationTokenProvider.cs b/Microsoft.Azure.Cosmos/src/ICosmosAuthorizationTokenProvider.cs index 10ccd212e..08d91dd35 100644 --- a/Microsoft.Azure.Cosmos/src/ICosmosAuthorizationTokenProvider.cs +++ b/Microsoft.Azure.Cosmos/src/ICosmosAuthorizationTokenProvider.cs @@ -4,8 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System; - using System.IO; using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Collections; diff --git a/Microsoft.Azure.Cosmos/src/IDocumentClientInternal.cs b/Microsoft.Azure.Cosmos/src/IDocumentClientInternal.cs index 351a809ba..6654fec3f 100644 --- a/Microsoft.Azure.Cosmos/src/IDocumentClientInternal.cs +++ b/Microsoft.Azure.Cosmos/src/IDocumentClientInternal.cs @@ -10,6 +10,6 @@ namespace Microsoft.Azure.Cosmos internal interface IDocumentClientInternal : IDocumentClient { - Task GetDatabaseAccountInternalAsync(Uri serviceEndpoint, CancellationToken cancellationToken = default(CancellationToken)); + Task GetDatabaseAccountInternalAsync(Uri serviceEndpoint, CancellationToken cancellationToken = default); } } diff --git a/Microsoft.Azure.Cosmos/src/Json/ByteOrder.cs b/Microsoft.Azure.Cosmos/src/Json/ByteOrder.cs index 2a62c4f3f..e4e0376eb 100644 --- a/Microsoft.Azure.Cosmos/src/Json/ByteOrder.cs +++ b/Microsoft.Azure.Cosmos/src/Json/ByteOrder.cs @@ -39,8 +39,8 @@ namespace Microsoft.Azure.Cosmos.Json /// The reversed char. public static char Reverse(char value) { - ushort b1 = (ushort)(((ushort)value >> 0) & 0xff); - ushort b2 = (ushort)(((ushort)value >> 8) & 0xff); + ushort b1 = (ushort)((value >> 0) & 0xff); + ushort b2 = (ushort)((value >> 8) & 0xff); return (char)((b1 << 8) | (b2 << 0)); } diff --git a/Microsoft.Azure.Cosmos/src/Json/IJsonNavigator.cs b/Microsoft.Azure.Cosmos/src/Json/IJsonNavigator.cs index b2af61139..23e6d9c59 100644 --- a/Microsoft.Azure.Cosmos/src/Json/IJsonNavigator.cs +++ b/Microsoft.Azure.Cosmos/src/Json/IJsonNavigator.cs @@ -5,8 +5,6 @@ namespace Microsoft.Azure.Cosmos.Json { using System; using System.Collections.Generic; - using Microsoft.Azure.Cosmos.Core.Utf8; - using Microsoft.Azure.Cosmos.Query.Core; /// /// JsonNavigator interface for classes that can navigate jsons. diff --git a/Microsoft.Azure.Cosmos/src/Json/IJsonReader.cs b/Microsoft.Azure.Cosmos/src/Json/IJsonReader.cs index e236a59ad..fff1743e8 100644 --- a/Microsoft.Azure.Cosmos/src/Json/IJsonReader.cs +++ b/Microsoft.Azure.Cosmos/src/Json/IJsonReader.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Json { using System; - using System.Collections.Generic; /// /// Interface for all JsonReaders that know how to read jsons. diff --git a/Microsoft.Azure.Cosmos/src/Json/IJsonTextWriterExtensions.cs b/Microsoft.Azure.Cosmos/src/Json/IJsonTextWriterExtensions.cs index 866da9a69..809635b1a 100644 --- a/Microsoft.Azure.Cosmos/src/Json/IJsonTextWriterExtensions.cs +++ b/Microsoft.Azure.Cosmos/src/Json/IJsonTextWriterExtensions.cs @@ -5,8 +5,6 @@ namespace Microsoft.Azure.Cosmos.Json { using System; - using System.Collections.Generic; - using System.Text; internal interface IJsonTextWriterExtensions : IJsonWriter { diff --git a/Microsoft.Azure.Cosmos/src/Json/IReadOnlyJsonStringDictionary.cs b/Microsoft.Azure.Cosmos/src/Json/IReadOnlyJsonStringDictionary.cs index c3adab206..6040b6a51 100644 --- a/Microsoft.Azure.Cosmos/src/Json/IReadOnlyJsonStringDictionary.cs +++ b/Microsoft.Azure.Cosmos/src/Json/IReadOnlyJsonStringDictionary.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Json { using System; - using Antlr4.Runtime.Tree; #if INTERNAL #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member diff --git a/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftReader.cs b/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftReader.cs index 9aa7422cb..ef1c9f11b 100644 --- a/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftReader.cs +++ b/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftReader.cs @@ -4,8 +4,6 @@ namespace Microsoft.Azure.Cosmos.Json.Interop { using System; - using System.IO; - using System.Linq; using Newtonsoft.Json; /// @@ -179,9 +177,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Reads the next JSON token from the source as a []. + /// Reads the next JSON token from the source as a []. /// - /// A [] or null if the next JSON token is null. This method will return null at the end of an array. + /// A [] or null if the next JSON token is null. This method will return null at the end of an array. public override byte[] ReadAsBytes() { throw new NotImplementedException(); @@ -226,9 +224,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Reads the next JSON token from the source as a of . + /// Reads the next JSON token from the source as a of . /// - /// A of . This method will return null at the end of an array. + /// A of . This method will return null at the end of an array. public override decimal? ReadAsDecimal() { decimal? value = (decimal?)this.ReadNumberValue(); @@ -241,9 +239,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Reads the next JSON token from the source as a of . + /// Reads the next JSON token from the source as a of . /// - /// A of . This method will return null at the end of an array. + /// A of . This method will return null at the end of an array. public override int? ReadAsInt32() { int? value = (int?)this.ReadNumberValue(); @@ -256,9 +254,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Reads the next JSON token from the source as a . + /// Reads the next JSON token from the source as a . /// - /// A . This method will return null at the end of an array. + /// A . This method will return null at the end of an array. public override string ReadAsString() { this.Read(); diff --git a/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftWriter.cs b/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftWriter.cs index 37ac76602..a78ecda55 100644 --- a/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Json/Interop/CosmosDBToNewtonsoftWriter.cs @@ -161,10 +161,10 @@ namespace Microsoft.Azure.Cosmos.Json.Interop #region WriteValue methods /// - /// Writes a value. + /// Writes a value. /// An error will raised if the value cannot be written as a single JSON token. /// - /// The value to write. + /// The value to write. public override void WriteValue(object value) { if (value is string stringValue) @@ -178,9 +178,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(string value) { base.WriteValue(value); @@ -188,27 +188,27 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(int value) { this.WriteValue((long)value); } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(uint value) { this.WriteValue((long)value); } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(long value) { base.WriteValue(value); @@ -216,9 +216,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(ulong value) { if (value <= long.MaxValue) @@ -232,18 +232,18 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(float value) { this.WriteValue((double)value); } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(double value) { base.WriteValue(value); @@ -251,9 +251,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(bool value) { base.WriteValue(value); @@ -261,27 +261,27 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(short value) { base.WriteValue((long)value); } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(ushort value) { this.WriteValue((long)value); } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(char value) { base.WriteValue(value); @@ -289,27 +289,27 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(byte value) { this.WriteValue((long)value); } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(sbyte value) { this.WriteValue((long)value); } /// - /// Writes a value. + /// Writes a value. /// - /// The value to write. + /// The value to write. public override void WriteValue(decimal value) { this.WriteValue((double)value); @@ -325,9 +325,9 @@ namespace Microsoft.Azure.Cosmos.Json.Interop } /// - /// Writes a [] value. + /// Writes a [] value. /// - /// The [] value to write. + /// The [] value to write. public override void WriteValue(byte[] value) { throw new NotSupportedException("Can not write byte arrays"); diff --git a/Microsoft.Azure.Cosmos/src/Json/Interop/NewtonsoftToCosmosDBWriter.cs b/Microsoft.Azure.Cosmos/src/Json/Interop/NewtonsoftToCosmosDBWriter.cs index 98da0507b..fde91c616 100644 --- a/Microsoft.Azure.Cosmos/src/Json/Interop/NewtonsoftToCosmosDBWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Json/Interop/NewtonsoftToCosmosDBWriter.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Json.Interop using System.IO; using System.Text; using Microsoft.Azure.Cosmos.Core.Utf8; - using Newtonsoft.Json; #if INTERNAL #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member @@ -29,13 +28,7 @@ namespace Microsoft.Azure.Cosmos.Json.Interop this.getResultCallback = getResultCallback ?? throw new ArgumentNullException(nameof(getResultCallback)); } - public override long CurrentLength - { - get - { - throw new NotImplementedException(); - } - } + public override long CurrentLength => throw new NotImplementedException(); public override JsonSerializationFormat SerializationFormat => JsonSerializationFormat.Text; diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.Enumerator.cs b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.Enumerator.cs index 5ba2f931d..3001de8bc 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.Enumerator.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.Enumerator.cs @@ -23,7 +23,7 @@ namespace Microsoft.Azure.Cosmos.Json int arrayLength = JsonBinaryEncoding.GetValueLength(buffer.Span); // Scope to just the array - buffer = buffer.Slice(0, (int)arrayLength); + buffer = buffer.Slice(0, arrayLength); // Seek to the first array item buffer = buffer.Slice(firstArrayItemOffset); diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.FirstValueOffsets.cs b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.FirstValueOffsets.cs index 47c7f0ee0..f94d858db 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.FirstValueOffsets.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.FirstValueOffsets.cs @@ -129,13 +129,7 @@ namespace Microsoft.Azure.Cosmos.Json 0, // Invalid }; - public static IReadOnlyList Offsets - { - get - { - return FirstValueOffsets.offsets; - } - } + public static IReadOnlyList Offsets => FirstValueOffsets.offsets; } } } diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.MultiByteTypeMarker.cs b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.MultiByteTypeMarker.cs index a9ea11eba..51d3eb2b5 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.MultiByteTypeMarker.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.MultiByteTypeMarker.cs @@ -4,10 +4,6 @@ namespace Microsoft.Azure.Cosmos.Json { - using System; - using System.Collections.Generic; - using System.Text; - internal static partial class JsonBinaryEncoding { /// diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.NodeTypes.cs b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.NodeTypes.cs index 041ac7608..9e22e67e8 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.NodeTypes.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.NodeTypes.cs @@ -142,7 +142,10 @@ namespace Microsoft.Azure.Cosmos.Json Unknown, // Invalid }; - public static JsonNodeType GetNodeType(byte typeMarker) => NodeTypes.Types[typeMarker]; + public static JsonNodeType GetNodeType(byte typeMarker) + { + return NodeTypes.Types[typeMarker]; + } } } } diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.StringLengths.cs b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.StringLengths.cs index d88255c32..9195b94cf 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.StringLengths.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.StringLengths.cs @@ -140,13 +140,7 @@ namespace Microsoft.Azure.Cosmos.Json NotStr, // Invalid }; - public static IReadOnlyList Lengths - { - get - { - return StringLengths.lengths; - } - } + public static IReadOnlyList Lengths => StringLengths.lengths; } } } diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.TypeMarker.cs b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.TypeMarker.cs index 57bc89b22..6781a7549 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.TypeMarker.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.TypeMarker.cs @@ -4,10 +4,7 @@ namespace Microsoft.Azure.Cosmos.Json { - using System; - using System.Collections.Generic; using System.Runtime.CompilerServices; - using System.Text; internal static partial class JsonBinaryEncoding { @@ -327,7 +324,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input integer. /// Whether an integer can be encoded as a literal. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsEncodedNumberLiteral(long value) => InRange(value, LiteralIntMin, LiteralIntMax); + public static bool IsEncodedNumberLiteral(long value) + { + return InRange(value, LiteralIntMin, LiteralIntMax); + } /// /// Gets whether an integer is a fixed length integer. @@ -335,7 +335,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input integer. /// Whether an integer is a fixed length integer. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsFixedLengthNumber(long value) => InRange(value, NumberUInt8, NumberDouble + 1); + public static bool IsFixedLengthNumber(long value) + { + return InRange(value, NumberUInt8, NumberDouble + 1); + } /// /// Gets whether an integer is a number. @@ -343,7 +346,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input integer. /// Whether an integer is a number. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsNumber(long value) => IsEncodedNumberLiteral(value) || IsFixedLengthNumber(value); + public static bool IsNumber(long value) + { + return IsEncodedNumberLiteral(value) || IsFixedLengthNumber(value); + } /// /// Encodes an integer as a literal. @@ -351,7 +357,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input integer. /// The integer encoded as a literal if it can; else Invalid [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static byte EncodeIntegerLiteral(long value) => IsEncodedNumberLiteral(value) ? (byte)(LiteralIntMin + value) : Invalid; + public static byte EncodeIntegerLiteral(long value) + { + return IsEncodedNumberLiteral(value) ? (byte)(LiteralIntMin + value) : Invalid; + } #endregion #region String Type Markers Utility Functions @@ -361,7 +370,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a system string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsSystemString(byte typeMarker) => InRange(typeMarker, SystemString1ByteLengthMin, SystemString1ByteLengthMax); + public static bool IsSystemString(byte typeMarker) + { + return InRange(typeMarker, SystemString1ByteLengthMin, SystemString1ByteLengthMax); + } /// /// Gets whether a typeMarker is for a one byte encoded user string. @@ -369,7 +381,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a one byte encoded user string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOneByteEncodedUserString(byte typeMarker) => InRange(typeMarker, UserString1ByteLengthMin, UserString1ByteLengthMax); + public static bool IsOneByteEncodedUserString(byte typeMarker) + { + return InRange(typeMarker, UserString1ByteLengthMin, UserString1ByteLengthMax); + } /// /// Gets whether a typeMarker is for a two byte encoded user string. @@ -377,7 +392,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a two byte encoded user string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsTwoByteEncodedUserString(byte typeMarker) => InRange(typeMarker, UserString2ByteLengthMin, UserString2ByteLengthMax); + public static bool IsTwoByteEncodedUserString(byte typeMarker) + { + return InRange(typeMarker, UserString2ByteLengthMin, UserString2ByteLengthMax); + } /// /// Gets whether a typeMarker is for a user string. @@ -385,7 +403,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a user string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsUserString(byte typeMarker) => IsOneByteEncodedUserString(typeMarker) || IsTwoByteEncodedUserString(typeMarker); + public static bool IsUserString(byte typeMarker) + { + return IsOneByteEncodedUserString(typeMarker) || IsTwoByteEncodedUserString(typeMarker); + } /// /// Gets whether a typeMarker is for a one byte encoded string. @@ -393,7 +414,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a one byte encoded string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOneByteEncodedString(byte typeMarker) => InRange(typeMarker, SystemString1ByteLengthMin, UserString1ByteLengthMax); + public static bool IsOneByteEncodedString(byte typeMarker) + { + return InRange(typeMarker, SystemString1ByteLengthMin, UserString1ByteLengthMax); + } /// /// Gets whether a typeMarker is for a two byte encoded string. @@ -401,7 +425,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a two byte encoded string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsTwoByteEncodedString(byte typeMarker) => IsTwoByteEncodedUserString(typeMarker); + public static bool IsTwoByteEncodedString(byte typeMarker) + { + return IsTwoByteEncodedUserString(typeMarker); + } /// /// Gets whether a typeMarker is for an encoded string. @@ -409,7 +436,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for an encoded string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsEncodedString(byte typeMarker) => InRange(typeMarker, SystemString1ByteLengthMin, UserString2ByteLengthMax); + public static bool IsEncodedString(byte typeMarker) + { + return InRange(typeMarker, SystemString1ByteLengthMin, UserString2ByteLengthMax); + } /// /// Gets whether a typeMarker is for an encoded length string. @@ -417,7 +447,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for an encoded string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsEncodedLengthString(byte typeMarker) => InRange(typeMarker, EncodedStringLengthMin, EncodedStringLengthMax); + public static bool IsEncodedLengthString(byte typeMarker) + { + return InRange(typeMarker, EncodedStringLengthMin, EncodedStringLengthMax); + } /// /// Gets whether a typeMarker is for a variable length string. @@ -425,7 +458,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a variable length string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsVarLengthString(byte typeMarker) => InRange(typeMarker, String1ByteLength, String4ByteLength + 1); + public static bool IsVarLengthString(byte typeMarker) + { + return InRange(typeMarker, String1ByteLength, String4ByteLength + 1); + } /// /// Gets whether a typeMarker is for a variable length compressed string. @@ -433,7 +469,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the typeMarker is for a variable length compressed string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsVarLengthCompressedString(byte typeMarker) => InRange(typeMarker, Binary1ByteLength, Binary4ByteLength + 1); + public static bool IsVarLengthCompressedString(byte typeMarker) + { + return InRange(typeMarker, Binary1ByteLength, Binary4ByteLength + 1); + } /// /// Gets whether a typeMarker is for a string. @@ -441,7 +480,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The type maker. /// Whether the typeMarker is for a string. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsString(byte typeMarker) => InRange(typeMarker, SystemString1ByteLengthMin, Binary4ByteLength + 1); + public static bool IsString(byte typeMarker) + { + return InRange(typeMarker, SystemString1ByteLengthMin, Binary4ByteLength + 1); + } /// /// Gets the length of a encoded string type marker. @@ -449,7 +491,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// The length of the encoded string type marker. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static long GetEncodedStringLength(byte typeMarker) => typeMarker & (EncodedStringLengthMin - 1); + public static long GetEncodedStringLength(byte typeMarker) + { + return typeMarker & (EncodedStringLengthMin - 1); + } /// /// Gets the type marker for an encoded string of a particular length. @@ -457,7 +502,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The length of the encoded string. /// The type marker for an encoded string of a particular length. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static byte GetEncodedStringLengthTypeMarker(long length) => length < (EncodedStringLengthMax - EncodedStringLengthMin) ? (byte)(length | EncodedStringLengthMin) : Invalid; + public static byte GetEncodedStringLengthTypeMarker(long length) + { + return length < (EncodedStringLengthMax - EncodedStringLengthMin) ? (byte)(length | EncodedStringLengthMin) : Invalid; + } #endregion #region Other Primitive Type Markers Utility Functions @@ -467,7 +515,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type maker is the null type marker. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsNull(byte typeMarker) => typeMarker == Null; + public static bool IsNull(byte typeMarker) + { + return typeMarker == Null; + } /// /// Gets whether a type maker is the false type marker. @@ -475,7 +526,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type maker is the false type marker. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsFalse(byte typeMarker) => typeMarker == False; + public static bool IsFalse(byte typeMarker) + { + return typeMarker == False; + } /// /// Gets whether a type maker is the true type marker. @@ -483,7 +537,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type maker is the true type marker. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsTrue(byte typeMarker) => typeMarker == True; + public static bool IsTrue(byte typeMarker) + { + return typeMarker == True; + } /// /// Gets whether a type maker is a boolean type marker. @@ -491,10 +548,16 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type maker is a boolean type marker. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsBoolean(byte typeMarker) => (typeMarker == False) || (typeMarker == True); + public static bool IsBoolean(byte typeMarker) + { + return (typeMarker == False) || (typeMarker == True); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsGuid(byte typeMarker) => typeMarker == Guid; + public static bool IsGuid(byte typeMarker) + { + return typeMarker == Guid; + } #endregion #region Array/Object Type Markers @@ -504,7 +567,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type marker is the empty array type marker. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsEmptyArray(byte typeMarker) => typeMarker == EmptyArray; + public static bool IsEmptyArray(byte typeMarker) + { + return typeMarker == EmptyArray; + } /// /// Gets whether a type marker is for an array. @@ -512,7 +578,10 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type marker is for an array. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsArray(byte typeMarker) => InRange(typeMarker, EmptyArray, Array4ByteLengthAndCount + 1); + public static bool IsArray(byte typeMarker) + { + return InRange(typeMarker, EmptyArray, Array4ByteLengthAndCount + 1); + } /// /// Gets whether a type marker is the empty object type marker. @@ -520,14 +589,21 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type marker is the empty object type marker. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsEmptyObject(byte typeMarker) => typeMarker == EmptyObject; + public static bool IsEmptyObject(byte typeMarker) + { + return typeMarker == EmptyObject; + } + /// /// Gets whether a type marker is for an object. /// /// The input type marker. /// Whether the type marker is for an object. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsObject(byte typeMarker) => InRange(typeMarker, EmptyObject, Object4ByteLengthAndCount + 1); + public static bool IsObject(byte typeMarker) + { + return InRange(typeMarker, EmptyObject, Object4ByteLengthAndCount + 1); + } #endregion #region Common Utility Functions @@ -537,10 +613,16 @@ namespace Microsoft.Azure.Cosmos.Json /// The input type marker. /// Whether the type marker is valid. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsValid(byte typeMarker) => typeMarker != Invalid; + public static bool IsValid(byte typeMarker) + { + return typeMarker != Invalid; + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool InRange(long value, long minInclusive, long maxExclusive) => (value >= minInclusive) && (value < maxExclusive); + private static bool InRange(long value, long minInclusive, long maxExclusive) + { + return (value >= minInclusive) && (value < maxExclusive); + } #endregion } } diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.cs b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.cs index 05294b6d4..24bf28612 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.cs @@ -192,7 +192,7 @@ namespace Microsoft.Azure.Cosmos.Json public static bool TryGetValueLength(ReadOnlySpan buffer, out int length) { // Too lazy to convert this right now. - length = (int)JsonBinaryEncoding.GetValueLength(buffer); + length = JsonBinaryEncoding.GetValueLength(buffer); return true; } @@ -202,7 +202,7 @@ namespace Microsoft.Azure.Cosmos.Json out T fixedWidthValue) where T : struct { - fixedWidthValue = default(T); + fixedWidthValue = default; int sizeofType = Marshal.SizeOf(fixedWidthValue); if (token.Length < 1 + sizeofType) { diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonMemoryReader.cs b/Microsoft.Azure.Cosmos/src/Json/JsonMemoryReader.cs index 93afadfc7..8fe6bd894 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonMemoryReader.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonMemoryReader.cs @@ -23,24 +23,36 @@ namespace Microsoft.Azure.Cosmos.Json [MethodImpl(MethodImplOptions.AggressiveInlining)] public byte Read() { - byte value = this.position < this.buffer.Length ? (byte)this.buffer.Span[this.position] : (byte)0; + byte value = this.position < this.buffer.Length ? this.buffer.Span[this.position] : (byte)0; this.position++; return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public byte Peek() => this.position < this.buffer.Length ? (byte)this.buffer.Span[this.position] : (byte)0; + public byte Peek() + { + return this.position < this.buffer.Length ? this.buffer.Span[this.position] : (byte)0; + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ReadOnlyMemory GetBufferedRawJsonToken() => this.buffer.Slice(this.position); + public ReadOnlyMemory GetBufferedRawJsonToken() + { + return this.buffer.Slice(this.position); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyMemory GetBufferedRawJsonToken( - int startPosition) => this.buffer.Slice(startPosition); + int startPosition) + { + return this.buffer.Slice(startPosition); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyMemory GetBufferedRawJsonToken( int startPosition, - int endPosition) => this.buffer.Slice(startPosition, endPosition - startPosition); + int endPosition) + { + return this.buffer.Slice(startPosition, endPosition - startPosition); + } } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonBinaryNavigator.cs b/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonBinaryNavigator.cs index 31d218520..85ef4cc12 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonBinaryNavigator.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonBinaryNavigator.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Cosmos.Json using System.Linq; using System.Runtime.InteropServices; using Microsoft.Azure.Cosmos.Core.Utf8; - using Microsoft.Azure.Cosmos.Json.Interop; /// /// Partial class that wraps the private JsonTextNavigator @@ -69,7 +68,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonSerializationFormat SerializationFormat => JsonSerializationFormat.Binary; /// - public override IJsonNavigatorNode GetRootNode() => this.rootNode; + public override IJsonNavigatorNode GetRootNode() + { + return this.rootNode; + } /// public override JsonNodeType GetNodeType(IJsonNavigatorNode node) @@ -298,9 +300,12 @@ namespace Microsoft.Azure.Cosmos.Json return this.GetArrayItemsInternal(buffer).Select((node) => (IJsonNavigatorNode)node); } - private IEnumerable GetArrayItemsInternal(ReadOnlyMemory buffer) => JsonBinaryEncoding.Enumerator - .GetArrayItems(buffer) - .Select(arrayItem => new BinaryNavigatorNode(arrayItem, JsonBinaryEncoding.NodeTypes.GetNodeType(arrayItem.Span[0]))); + private IEnumerable GetArrayItemsInternal(ReadOnlyMemory buffer) + { + return JsonBinaryEncoding.Enumerator +.GetArrayItems(buffer) +.Select(arrayItem => new BinaryNavigatorNode(arrayItem, JsonBinaryEncoding.NodeTypes.GetNodeType(arrayItem.Span[0]))); + } /// public override int GetObjectPropertyCount(IJsonNavigatorNode objectNode) @@ -407,11 +412,14 @@ namespace Microsoft.Azure.Cosmos.Json objectPropertyInternal.ValueNode)); } - private IEnumerable GetObjectPropertiesInternal(ReadOnlyMemory buffer) => JsonBinaryEncoding.Enumerator - .GetObjectProperties(buffer) - .Select(property => new ObjectPropertyInternal( - new BinaryNavigatorNode(property.Name, JsonNodeType.FieldName), - new BinaryNavigatorNode(property.Value, JsonBinaryEncoding.NodeTypes.GetNodeType(property.Value.Span[0])))); + private IEnumerable GetObjectPropertiesInternal(ReadOnlyMemory buffer) + { + return JsonBinaryEncoding.Enumerator +.GetObjectProperties(buffer) +.Select(property => new ObjectPropertyInternal( +new BinaryNavigatorNode(property.Name, JsonNodeType.FieldName), +new BinaryNavigatorNode(property.Value, JsonBinaryEncoding.NodeTypes.GetNodeType(property.Value.Span[0])))); + } public override IJsonReader CreateReader(IJsonNavigatorNode jsonNavigatorNode) { @@ -449,7 +457,7 @@ namespace Microsoft.Azure.Cosmos.Json int arrayLength = JsonBinaryEncoding.GetValueLength(buffer.Span); // Scope to just the array - buffer = buffer.Slice(0, (int)arrayLength); + buffer = buffer.Slice(0, arrayLength); // Seek to the first array item buffer = buffer.Slice(firstArrayItemOffset); diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonTextNavigator.cs b/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonTextNavigator.cs index 4dc9908f7..d230619fb 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonTextNavigator.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonNavigator.JsonTextNavigator.cs @@ -92,7 +92,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonSerializationFormat SerializationFormat => JsonSerializationFormat.Text; /// - public override IJsonNavigatorNode GetRootNode() => this.rootNode; + public override IJsonNavigatorNode GetRootNode() + { + return this.rootNode; + } /// public override JsonNodeType GetNodeType(IJsonNavigatorNode node) @@ -415,22 +418,25 @@ namespace Microsoft.Azure.Cosmos.Json return JsonReader.Create(JsonSerializationFormat.Text, buffer); } - private static ReadOnlyMemory GetNodeBuffer(JsonTextNavigatorNode jsonTextNavigatorNode) => jsonTextNavigatorNode switch + private static ReadOnlyMemory GetNodeBuffer(JsonTextNavigatorNode jsonTextNavigatorNode) { - LazyNode lazyNode => lazyNode.BufferedValue, - ArrayNode arrayNode => arrayNode.BufferedValue, - FalseNode falseNode => SingletonBuffers.False, - StringNodeBase stringNodeBase => stringNodeBase.BufferedValue.Memory, - NullNode nullNode => SingletonBuffers.Null, - NumberNode numberNode => numberNode.BufferedToken, - ObjectNode objectNode => objectNode.BufferedValue, - TrueNode trueNode => SingletonBuffers.True, - GuidNode guidNode => guidNode.BufferedToken, - BinaryNode binaryNode => binaryNode.BufferedToken, - IntegerNode intNode => intNode.BufferedToken, - FloatNode floatNode => floatNode.BufferedToken, - _ => throw new ArgumentOutOfRangeException($"Unknown {nameof(JsonTextNavigatorNode)} type: {jsonTextNavigatorNode.GetType()}."), - }; + return jsonTextNavigatorNode switch + { + LazyNode lazyNode => lazyNode.BufferedValue, + ArrayNode arrayNode => arrayNode.BufferedValue, + FalseNode falseNode => SingletonBuffers.False, + StringNodeBase stringNodeBase => stringNodeBase.BufferedValue.Memory, + NullNode nullNode => SingletonBuffers.Null, + NumberNode numberNode => numberNode.BufferedToken, + ObjectNode objectNode => objectNode.BufferedValue, + TrueNode trueNode => SingletonBuffers.True, + GuidNode guidNode => guidNode.BufferedToken, + BinaryNode binaryNode => binaryNode.BufferedToken, + IntegerNode intNode => intNode.BufferedToken, + FloatNode floatNode => floatNode.BufferedToken, + _ => throw new ArgumentOutOfRangeException($"Unknown {nameof(JsonTextNavigatorNode)} type: {jsonTextNavigatorNode.GetType()}."), + }; + } #region JsonTextParser /// @@ -777,7 +783,10 @@ namespace Microsoft.Azure.Cosmos.Json public static ArrayNode Create( IReadOnlyList items, - ReadOnlyMemory bufferedValue) => new ArrayNode(items, bufferedValue); + ReadOnlyMemory bufferedValue) + { + return new ArrayNode(items, bufferedValue); + } } private sealed class FalseNode : JsonTextNavigatorNode @@ -909,7 +918,10 @@ namespace Microsoft.Azure.Cosmos.Json public static ObjectNode Create( IReadOnlyList properties, - ReadOnlyMemory bufferedValue) => new ObjectNode(properties, bufferedValue); + ReadOnlyMemory bufferedValue) + { + return new ObjectNode(properties, bufferedValue); + } } private sealed class StringNode : StringNodeBase @@ -981,7 +993,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Int8; - public static Int8Node Create(ReadOnlyMemory bufferedToken) => new Int8Node(bufferedToken); + public static Int8Node Create(ReadOnlyMemory bufferedToken) + { + return new Int8Node(bufferedToken); + } } private sealed class Int16Node : IntegerNode @@ -993,7 +1008,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Int16; - public static Int16Node Create(ReadOnlyMemory bufferedToken) => new Int16Node(bufferedToken); + public static Int16Node Create(ReadOnlyMemory bufferedToken) + { + return new Int16Node(bufferedToken); + } } private sealed class Int32Node : IntegerNode @@ -1005,7 +1023,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Int32; - public static Int32Node Create(ReadOnlyMemory bufferedToken) => new Int32Node(bufferedToken); + public static Int32Node Create(ReadOnlyMemory bufferedToken) + { + return new Int32Node(bufferedToken); + } } private sealed class Int64Node : IntegerNode @@ -1017,7 +1038,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Int64; - public static Int64Node Create(ReadOnlyMemory bufferedToken) => new Int64Node(bufferedToken); + public static Int64Node Create(ReadOnlyMemory bufferedToken) + { + return new Int64Node(bufferedToken); + } } private sealed class UInt32Node : IntegerNode @@ -1029,7 +1053,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.UInt32; - public static UInt32Node Create(ReadOnlyMemory bufferedToken) => new UInt32Node(bufferedToken); + public static UInt32Node Create(ReadOnlyMemory bufferedToken) + { + return new UInt32Node(bufferedToken); + } } private abstract class FloatNode : JsonTextNavigatorNode @@ -1051,7 +1078,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Float32; - public static Float32Node Create(ReadOnlyMemory bufferedToken) => new Float32Node(bufferedToken); + public static Float32Node Create(ReadOnlyMemory bufferedToken) + { + return new Float32Node(bufferedToken); + } } private sealed class Float64Node : FloatNode @@ -1063,7 +1093,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Float64; - public static Float64Node Create(ReadOnlyMemory bufferedToken) => new Float64Node(bufferedToken); + public static Float64Node Create(ReadOnlyMemory bufferedToken) + { + return new Float64Node(bufferedToken); + } } private sealed class GuidNode : JsonTextNavigatorNode @@ -1077,7 +1110,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Guid; - public static GuidNode Create(ReadOnlyMemory value) => new GuidNode(value); + public static GuidNode Create(ReadOnlyMemory value) + { + return new GuidNode(value); + } } private sealed class BinaryNode : JsonTextNavigatorNode @@ -1091,7 +1127,10 @@ namespace Microsoft.Azure.Cosmos.Json public override JsonNodeType Type => JsonNodeType.Binary; - public static BinaryNode Create(ReadOnlyMemory value) => new BinaryNode(value); + public static BinaryNode Create(ReadOnlyMemory value) + { + return new BinaryNode(value); + } } private abstract class LazyNode : JsonTextNavigatorNode diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonObjectState.cs b/Microsoft.Azure.Cosmos/src/Json/JsonObjectState.cs index db9885c55..10e699701 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonObjectState.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonObjectState.cs @@ -86,13 +86,7 @@ namespace Microsoft.Azure.Cosmos.Json /// /// Gets the current depth (level of nesting). /// - public int CurrentDepth - { - get - { - return this.nestingStackIndex + 1; - } - } + public int CurrentDepth => this.nestingStackIndex + 1; /// /// Gets the current JsonTokenType. @@ -102,35 +96,17 @@ namespace Microsoft.Azure.Cosmos.Json /// /// Gets a value indicating whether a property is expected. /// - public bool IsPropertyExpected - { - get - { - return (this.CurrentTokenType != JsonTokenType.FieldName) && (this.currentContext == JsonObjectContext.Object); - } - } + public bool IsPropertyExpected => (this.CurrentTokenType != JsonTokenType.FieldName) && (this.currentContext == JsonObjectContext.Object); /// /// Gets a value indicating whether the current context is an array. /// - public bool InArrayContext - { - get - { - return this.currentContext == JsonObjectContext.Array; - } - } + public bool InArrayContext => this.currentContext == JsonObjectContext.Array; /// /// Gets a value indicating whether the current context in an object. /// - public bool InObjectContext - { - get - { - return this.currentContext == JsonObjectContext.Object; - } - } + public bool InObjectContext => this.currentContext == JsonObjectContext.Object; /// /// Gets the current JsonObjectContext @@ -151,13 +127,7 @@ namespace Microsoft.Azure.Cosmos.Json /// /// Gets a mask to use to get the current context from the nesting stack /// - private byte Mask - { - get - { - return (byte)(1 << (this.nestingStackIndex % 8)); - } - } + private byte Mask => (byte)(1 << (this.nestingStackIndex % 8)); /// /// Registers a JsonTokenType. diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonBinaryReader.cs b/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonBinaryReader.cs index 4be8f3122..a001197a0 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonBinaryReader.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonBinaryReader.cs @@ -180,13 +180,7 @@ namespace Microsoft.Azure.Cosmos.Json } /// - public override JsonSerializationFormat SerializationFormat - { - get - { - return JsonSerializationFormat.Binary; - } - } + public override JsonSerializationFormat SerializationFormat => JsonSerializationFormat.Binary; /// public override bool Read() diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonTextReader.cs b/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonTextReader.cs index 51ceb5a2b..c565e1fa0 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonTextReader.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonReader.JsonTextReader.cs @@ -738,7 +738,7 @@ namespace Microsoft.Azure.Cosmos.Json break; case '\\': - this.token.JsonTextTokenType = (JsonTextTokenType)(this.token.JsonTextTokenType | JsonTextTokenType.EscapedFlag); + this.token.JsonTextTokenType = this.token.JsonTextTokenType | JsonTextTokenType.EscapedFlag; char escapeCharacter = this.jsonTextBuffer.ReadCharacter(); if (escapeCharacter == 'u') { diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonSerializer.cs b/Microsoft.Azure.Cosmos/src/Json/JsonSerializer.cs index a9e53de32..0857feed3 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonSerializer.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonSerializer.cs @@ -262,7 +262,7 @@ namespace Microsoft.Azure.Cosmos.Json return TryCatch.FromException(Visitor.Exceptions.ExpectedBinary); } - return TryCatch.FromResult((object)cosmosBinary.Value); + return TryCatch.FromResult(cosmosBinary.Value); } public TryCatch Visit(CosmosBoolean cosmosBoolean, Type type) @@ -282,7 +282,7 @@ namespace Microsoft.Azure.Cosmos.Json return TryCatch.FromException(Visitor.Exceptions.ExpectedGuid); } - return TryCatch.FromResult((object)cosmosGuid.Value); + return TryCatch.FromResult(cosmosGuid.Value); } public TryCatch Visit(CosmosNull cosmosNull, Type type) @@ -299,7 +299,7 @@ namespace Microsoft.Azure.Cosmos.Json { if (type == typeof(Number64)) { - return TryCatch.FromResult((object)cosmosNumber.Value); + return TryCatch.FromResult(cosmosNumber.Value); } switch (Type.GetTypeCode(type)) @@ -319,7 +319,7 @@ namespace Microsoft.Azure.Cosmos.Json new OverflowException($"{value} was out of range for byte.")); } - return TryCatch.FromResult((object)(byte)value); + return TryCatch.FromResult((byte)value); } case TypeCode.Decimal: @@ -334,7 +334,7 @@ namespace Microsoft.Azure.Cosmos.Json value = Number64.ToLong(cosmosNumber.Value); } - return TryCatch.FromResult((object)value); + return TryCatch.FromResult(value); } case TypeCode.Double: @@ -346,7 +346,7 @@ namespace Microsoft.Azure.Cosmos.Json } double value = Number64.ToDouble(cosmosNumber.Value); - return TryCatch.FromResult((object)value); + return TryCatch.FromResult(value); } case TypeCode.Int16: @@ -364,7 +364,7 @@ namespace Microsoft.Azure.Cosmos.Json new OverflowException($"{value} was out of range for short.")); } - return TryCatch.FromResult((object)(short)value); + return TryCatch.FromResult((short)value); } case TypeCode.Int32: @@ -382,7 +382,7 @@ namespace Microsoft.Azure.Cosmos.Json new OverflowException($"{value} was out of range for int.")); } - return TryCatch.FromResult((object)(int)value); + return TryCatch.FromResult((int)value); } case TypeCode.Int64: @@ -394,7 +394,7 @@ namespace Microsoft.Azure.Cosmos.Json } long value = Number64.ToLong(cosmosNumber.Value); - return TryCatch.FromResult((object)(long)value); + return TryCatch.FromResult(value); } case TypeCode.SByte: @@ -412,7 +412,7 @@ namespace Microsoft.Azure.Cosmos.Json new OverflowException($"{value} was out of range for sbyte.")); } - return TryCatch.FromResult((object)(sbyte)value); + return TryCatch.FromResult((sbyte)value); } case TypeCode.Single: @@ -430,7 +430,7 @@ namespace Microsoft.Azure.Cosmos.Json new OverflowException($"{value} was out of range for float.")); } - return TryCatch.FromResult((object)(float)value); + return TryCatch.FromResult((float)value); } case TypeCode.UInt16: @@ -448,7 +448,7 @@ namespace Microsoft.Azure.Cosmos.Json new OverflowException($"{value} was out of range for ushort.")); } - return TryCatch.FromResult((object)(ushort)value); + return TryCatch.FromResult((ushort)value); } case TypeCode.UInt32: @@ -466,7 +466,7 @@ namespace Microsoft.Azure.Cosmos.Json new OverflowException($"{value} was out of range for uint.")); } - return TryCatch.FromResult((object)(uint)value); + return TryCatch.FromResult((uint)value); } case TypeCode.UInt64: @@ -478,7 +478,7 @@ namespace Microsoft.Azure.Cosmos.Json } long value = Number64.ToLong(cosmosNumber.Value); - return TryCatch.FromResult((object)(ulong)value); + return TryCatch.FromResult((ulong)value); } default: @@ -544,7 +544,7 @@ namespace Microsoft.Azure.Cosmos.Json return TryCatch.FromException(Visitor.Exceptions.ExpectedString); } - return TryCatch.FromResult((object)cosmosString.Value); + return TryCatch.FromResult(cosmosString.Value); } } diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonTextParser.cs b/Microsoft.Azure.Cosmos/src/Json/JsonTextParser.cs index b67a73a44..1a8b65558 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonTextParser.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonTextParser.cs @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Cosmos.Json using System; using System.Buffers.Text; using System.Text; - using Microsoft.Azure.Cosmos.Query.Core; /// /// Common utility class for JsonTextReader and JsonTextNavigator. @@ -100,7 +99,7 @@ namespace Microsoft.Azure.Cosmos.Json throw new ArgumentOutOfRangeException($"Tried to read {value} as an {typeof(long).FullName}"); } - return (long)value; + return value; } public static uint GetUInt32Value(ReadOnlySpan intToken) diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonBinaryWriter.cs b/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonBinaryWriter.cs index 939f39784..6016d57a7 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonBinaryWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonBinaryWriter.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Json using System.Buffers.Binary; using System.Collections.Generic; using System.Runtime.InteropServices; - using System.Text; using Microsoft.Azure.Cosmos.Core.Utf8; /// @@ -86,22 +85,10 @@ namespace Microsoft.Azure.Cosmos.Json } /// - public override JsonSerializationFormat SerializationFormat - { - get - { - return JsonSerializationFormat.Binary; - } - } + public override JsonSerializationFormat SerializationFormat => JsonSerializationFormat.Binary; /// - public override long CurrentLength - { - get - { - return this.binaryWriter.Position; - } - } + public override long CurrentLength => this.binaryWriter.Position; /// public override void WriteObjectStart() @@ -562,7 +549,7 @@ namespace Microsoft.Azure.Cosmos.Json else { this.binaryWriter.Write(JsonBinaryEncoding.TypeMarker.NumberInt64); - this.binaryWriter.Write((long)value); + this.binaryWriter.Write(value); } } else @@ -571,7 +558,7 @@ namespace Microsoft.Azure.Cosmos.Json if (value < int.MinValue) { this.binaryWriter.Write(JsonBinaryEncoding.TypeMarker.NumberInt64); - this.binaryWriter.Write((long)value); + this.binaryWriter.Write(value); } else if (value < short.MinValue) { diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonTextWriter.cs b/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonTextWriter.cs index 103970b1e..09b19989d 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonTextWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonTextWriter.cs @@ -7,11 +7,8 @@ namespace Microsoft.Azure.Cosmos.Json using System.Buffers; using System.Buffers.Text; using System.Globalization; - using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; - using System.Text; using Microsoft.Azure.Cosmos.Core.Utf8; /// @@ -104,22 +101,10 @@ namespace Microsoft.Azure.Cosmos.Json } /// - public override JsonSerializationFormat SerializationFormat - { - get - { - return JsonSerializationFormat.Text; - } - } + public override JsonSerializationFormat SerializationFormat => JsonSerializationFormat.Text; /// - public override long CurrentLength - { - get - { - return this.jsonTextMemoryWriter.Position; - } - } + public override long CurrentLength => this.jsonTextMemoryWriter.Position; /// public override void WriteObjectStart() diff --git a/Microsoft.Azure.Cosmos/src/Json/JsonWriter.cs b/Microsoft.Azure.Cosmos/src/Json/JsonWriter.cs index 26012bbb8..d08e676aa 100644 --- a/Microsoft.Azure.Cosmos/src/Json/JsonWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Json/JsonWriter.cs @@ -51,7 +51,9 @@ namespace Microsoft.Azure.Cosmos.Json public static IJsonWriter Create( JsonSerializationFormat jsonSerializationFormat, JsonStringDictionary jsonStringDictionary = null, - int initalCapacity = 256) => jsonSerializationFormat switch + int initalCapacity = 256) + { + return jsonSerializationFormat switch { JsonSerializationFormat.Text => new JsonTextWriter(initalCapacity), JsonSerializationFormat.Binary => new JsonBinaryWriter( @@ -63,6 +65,7 @@ namespace Microsoft.Azure.Cosmos.Json RMResources.UnexpectedJsonSerializationFormat, jsonSerializationFormat)), }; + } /// public abstract void WriteObjectStart(); diff --git a/Microsoft.Azure.Cosmos/src/Json/Utf8Memory.cs b/Microsoft.Azure.Cosmos/src/Json/Utf8Memory.cs index 4159723a1..9b5c78182 100644 --- a/Microsoft.Azure.Cosmos/src/Json/Utf8Memory.cs +++ b/Microsoft.Azure.Cosmos/src/Json/Utf8Memory.cs @@ -31,10 +31,16 @@ namespace Microsoft.Azure.Cosmos.Json public Utf8Span Span => Utf8Span.UnsafeFromUtf8BytesNoValidation(this.Memory.Span); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Utf8Memory Slice(int start) => new Utf8Memory(this.Memory.Slice(start)); + public Utf8Memory Slice(int start) + { + return new Utf8Memory(this.Memory.Slice(start)); + } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Utf8Memory Slice(int start, int length) => new Utf8Memory(this.Memory.Slice(start, length)); + public Utf8Memory Slice(int start, int length) + { + return new Utf8Memory(this.Memory.Slice(start, length)); + } public bool IsEmpty => this.Memory.IsEmpty; public int Length => this.Memory.Length; diff --git a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ArrayBuiltinFunctions.cs b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ArrayBuiltinFunctions.cs index 1f520c64a..8c7479c82 100644 --- a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ArrayBuiltinFunctions.cs +++ b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ArrayBuiltinFunctions.cs @@ -105,7 +105,6 @@ namespace Microsoft.Azure.Cosmos.Linq { if (methodCallExpression.Arguments.Count == 1) { - List arguments = new List(); SqlScalarExpression array = ExpressionToSql.VisitScalarExpression(methodCallExpression.Arguments[0], context); return SqlFunctionCallScalarExpression.CreateBuiltin("ARRAY_LENGTH", array); @@ -140,12 +139,9 @@ namespace Microsoft.Azure.Cosmos.Linq { protected override SqlScalarExpression VisitImplicit(MethodCallExpression methodCallExpression, TranslationContext context) { - if (methodCallExpression.Arguments.Count == 1) - { - return ExpressionToSql.VisitScalarExpression(methodCallExpression.Arguments[0], context); - } - - return null; + return methodCallExpression.Arguments.Count == 1 + ? ExpressionToSql.VisitScalarExpression(methodCallExpression.Arguments[0], context) + : null; } protected override SqlScalarExpression VisitExplicit(MethodCallExpression methodCallExpression, TranslationContext context) @@ -156,36 +152,40 @@ namespace Microsoft.Azure.Cosmos.Linq static ArrayBuiltinFunctions() { - ArrayBuiltinFunctionDefinitions = new Dictionary(); - - ArrayBuiltinFunctionDefinitions.Add("Concat", - new ArrayConcatVisitor()); - - ArrayBuiltinFunctionDefinitions.Add("Contains", - new ArrayContainsVisitor()); - - ArrayBuiltinFunctionDefinitions.Add("Count", - new ArrayCountVisitor()); - - ArrayBuiltinFunctionDefinitions.Add("get_Item", - new ArrayGetItemVisitor()); - - ArrayBuiltinFunctionDefinitions.Add("ToArray", - new ArrayToArrayVisitor()); - - ArrayBuiltinFunctionDefinitions.Add("ToList", - new ArrayToArrayVisitor()); + ArrayBuiltinFunctionDefinitions = new Dictionary + { + { + "Concat", + new ArrayConcatVisitor() + }, + { + "Contains", + new ArrayContainsVisitor() + }, + { + "Count", + new ArrayCountVisitor() + }, + { + "get_Item", + new ArrayGetItemVisitor() + }, + { + "ToArray", + new ArrayToArrayVisitor() + }, + { + "ToList", + new ArrayToArrayVisitor() + } + }; } public static SqlScalarExpression Visit(MethodCallExpression methodCallExpression, TranslationContext context) { - BuiltinFunctionVisitor visitor = null; - if (ArrayBuiltinFunctionDefinitions.TryGetValue(methodCallExpression.Method.Name, out visitor)) - { - return visitor.Visit(methodCallExpression, context); - } - - throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.MethodNotSupported, methodCallExpression.Method.Name)); + return ArrayBuiltinFunctionDefinitions.TryGetValue(methodCallExpression.Method.Name, out BuiltinFunctionVisitor visitor) + ? visitor.Visit(methodCallExpression, context) + : throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.MethodNotSupported, methodCallExpression.Method.Name)); } } } diff --git a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ChangeFeedQuery.cs b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ChangeFeedQuery.cs index 54c5c1c47..d4181c4c7 100644 --- a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ChangeFeedQuery.cs +++ b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/ChangeFeedQuery.cs @@ -28,9 +28,10 @@ namespace Microsoft.Azure.Cosmos.Linq private readonly DocumentClient client; private readonly string resourceLink; private readonly ChangeFeedOptions feedOptions; + private readonly string ifModifiedSince; private HttpStatusCode lastStatusCode = HttpStatusCode.OK; private string nextIfNoneMatch; - private string ifModifiedSince; + #endregion Fields #region Constructor @@ -80,20 +81,14 @@ namespace Microsoft.Azure.Cosmos.Linq /// /// Boolean value representing if whether there are potentially additional results that can be retrieved. /// Initially returns true. This value is set based on whether the last execution returned a continuation token. - public bool HasMoreResults - { - get - { - return this.lastStatusCode != HttpStatusCode.NotModified; - } - } + public bool HasMoreResults => this.lastStatusCode != HttpStatusCode.NotModified; /// /// Read feed and retrieves the next page of results in the Azure Cosmos DB service. /// /// The type of the object returned in the query result. /// The Task object for the asynchronous response from query execution. - public Task> ExecuteNextAsync(CancellationToken cancellationToken = default(CancellationToken)) + public Task> ExecuteNextAsync(CancellationToken cancellationToken = default) { return this.ReadDocumentChangeFeedAsync(this.resourceLink, cancellationToken); } @@ -103,7 +98,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// /// (Optional) The allows for notification that operations should be cancelled. /// The Task object for the asynchronous response from query execution. - public Task> ExecuteNextAsync(CancellationToken cancellationToken = default(CancellationToken)) + public Task> ExecuteNextAsync(CancellationToken cancellationToken = default) { return this.ExecuteNextAsync(cancellationToken); } @@ -126,8 +121,7 @@ namespace Microsoft.Azure.Cosmos.Linq if (response.ResponseBody != null && response.ResponseBody.Length > 0) { long responseLengthInBytes = response.ResponseBody.Length; - int itemCount = 0; - IEnumerable feedResource = response.GetQueryResponse(typeof(TResource), out itemCount); + IEnumerable feedResource = response.GetQueryResponse(typeof(TResource), out int itemCount); DocumentFeedResponse feedResponse = new DocumentFeedResponse( feedResource, itemCount, diff --git a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/MathBuiltinFunctions.cs b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/MathBuiltinFunctions.cs index 228c6c28a..f6908cd1d 100644 --- a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/MathBuiltinFunctions.cs +++ b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/MathBuiltinFunctions.cs @@ -16,10 +16,11 @@ namespace Microsoft.Azure.Cosmos.Linq static MathBuiltinFunctions() { - MathBuiltinFunctionDefinitions = new Dictionary(); - - MathBuiltinFunctionDefinitions.Add("Abs", - new SqlBuiltinFunctionVisitor("ABS", + MathBuiltinFunctionDefinitions = new Dictionary + { + { + "Abs", + new SqlBuiltinFunctionVisitor("ABS", true, new List() { @@ -30,110 +31,123 @@ namespace Microsoft.Azure.Cosmos.Linq new Type[]{typeof(long)}, new Type[]{typeof(sbyte)}, new Type[]{typeof(short)}, - })); - - MathBuiltinFunctionDefinitions.Add("Acos", - new SqlBuiltinFunctionVisitor("ACOS", + }) + }, + { + "Acos", + new SqlBuiltinFunctionVisitor("ACOS", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Asin", - new SqlBuiltinFunctionVisitor("ASIN", + }) + }, + { + "Asin", + new SqlBuiltinFunctionVisitor("ASIN", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Atan", - new SqlBuiltinFunctionVisitor("ATAN", + }) + }, + { + "Atan", + new SqlBuiltinFunctionVisitor("ATAN", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Atan2", - new SqlBuiltinFunctionVisitor("ATN2", + }) + }, + { + "Atan2", + new SqlBuiltinFunctionVisitor("ATN2", true, new List() { new Type[]{typeof(double), typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Ceiling", - new SqlBuiltinFunctionVisitor("CEILING", + }) + }, + { + "Ceiling", + new SqlBuiltinFunctionVisitor("CEILING", true, new List() { new Type[]{typeof(decimal)}, new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Cos", - new SqlBuiltinFunctionVisitor("COS", + }) + }, + { + "Cos", + new SqlBuiltinFunctionVisitor("COS", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Exp", - new SqlBuiltinFunctionVisitor("EXP", + }) + }, + { + "Exp", + new SqlBuiltinFunctionVisitor("EXP", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Floor", - new SqlBuiltinFunctionVisitor("FLOOR", + }) + }, + { + "Floor", + new SqlBuiltinFunctionVisitor("FLOOR", true, new List() { new Type[]{typeof(decimal)}, new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Log", - new SqlBuiltinFunctionVisitor("LOG", + }) + }, + { + "Log", + new SqlBuiltinFunctionVisitor("LOG", true, new List() { new Type[]{typeof(double)}, new Type[]{typeof(double), typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Log10", - new SqlBuiltinFunctionVisitor("LOG10", + }) + }, + { + "Log10", + new SqlBuiltinFunctionVisitor("LOG10", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Pow", - new SqlBuiltinFunctionVisitor("POWER", + }) + }, + { + "Pow", + new SqlBuiltinFunctionVisitor("POWER", true, new List() { new Type[]{typeof(double), typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Round", - new SqlBuiltinFunctionVisitor("ROUND", + }) + }, + { + "Round", + new SqlBuiltinFunctionVisitor("ROUND", true, new List() { new Type[]{typeof(decimal)}, new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Sign", - new SqlBuiltinFunctionVisitor("SIGN", + }) + }, + { + "Sign", + new SqlBuiltinFunctionVisitor("SIGN", true, new List() { @@ -144,51 +158,53 @@ namespace Microsoft.Azure.Cosmos.Linq new Type[]{typeof(long)}, new Type[]{typeof(sbyte)}, new Type[]{typeof(short)}, - })); - - MathBuiltinFunctionDefinitions.Add("Sin", - new SqlBuiltinFunctionVisitor("SIN", + }) + }, + { + "Sin", + new SqlBuiltinFunctionVisitor("SIN", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Sqrt", - new SqlBuiltinFunctionVisitor("SQRT", + }) + }, + { + "Sqrt", + new SqlBuiltinFunctionVisitor("SQRT", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Tan", - new SqlBuiltinFunctionVisitor("TAN", + }) + }, + { + "Tan", + new SqlBuiltinFunctionVisitor("TAN", true, new List() { new Type[]{typeof(double)} - })); - - MathBuiltinFunctionDefinitions.Add("Truncate", - new SqlBuiltinFunctionVisitor("TRUNC", + }) + }, + { + "Truncate", + new SqlBuiltinFunctionVisitor("TRUNC", true, new List() { new Type[]{typeof(decimal)}, new Type[]{typeof(double)} - })); + }) + } + }; } public static SqlScalarExpression Visit(MethodCallExpression methodCallExpression, TranslationContext context) { - BuiltinFunctionVisitor visitor = null; - if (MathBuiltinFunctionDefinitions.TryGetValue(methodCallExpression.Method.Name, out visitor)) - { - return visitor.Visit(methodCallExpression, context); - } - - throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.MethodNotSupported, methodCallExpression.Method.Name)); + return MathBuiltinFunctionDefinitions.TryGetValue(methodCallExpression.Method.Name, out BuiltinFunctionVisitor visitor) + ? visitor.Visit(methodCallExpression, context) + : throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.MethodNotSupported, methodCallExpression.Method.Name)); } } } diff --git a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/TypeCheckFunctions.cs b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/TypeCheckFunctions.cs index ed3ec3463..93c09d65a 100644 --- a/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/TypeCheckFunctions.cs +++ b/Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/TypeCheckFunctions.cs @@ -16,42 +16,43 @@ namespace Microsoft.Azure.Cosmos.Linq static TypeCheckFunctions() { - TypeCheckFunctionsDefinitions = new Dictionary(); - - TypeCheckFunctionsDefinitions.Add("IsDefined", - new SqlBuiltinFunctionVisitor("IS_DEFINED", + TypeCheckFunctionsDefinitions = new Dictionary + { + { + "IsDefined", + new SqlBuiltinFunctionVisitor("IS_DEFINED", true, new List() { new Type[]{typeof(object)}, - })); - - TypeCheckFunctionsDefinitions.Add("IsNull", - new SqlBuiltinFunctionVisitor("IS_NULL", + }) + }, + { + "IsNull", + new SqlBuiltinFunctionVisitor("IS_NULL", true, new List() { new Type[]{typeof(object)}, - })); - - TypeCheckFunctionsDefinitions.Add("IsPrimitive", - new SqlBuiltinFunctionVisitor("IS_PRIMITIVE", + }) + }, + { + "IsPrimitive", + new SqlBuiltinFunctionVisitor("IS_PRIMITIVE", true, new List() { new Type[]{typeof(object)}, - })); + }) + } + }; } public static SqlScalarExpression Visit(MethodCallExpression methodCallExpression, TranslationContext context) { - BuiltinFunctionVisitor visitor = null; - if (TypeCheckFunctionsDefinitions.TryGetValue(methodCallExpression.Method.Name, out visitor)) - { - return visitor.Visit(methodCallExpression, context); - } - - throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.MethodNotSupported, methodCallExpression.Method.Name)); + return TypeCheckFunctionsDefinitions.TryGetValue(methodCallExpression.Method.Name, out BuiltinFunctionVisitor visitor) + ? visitor.Visit(methodCallExpression, context) + : throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.MethodNotSupported, methodCallExpression.Method.Name)); } } } diff --git a/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqExtensions.cs b/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqExtensions.cs index 7bf5b68e0..d2b241983 100644 --- a/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqExtensions.cs +++ b/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqExtensions.cs @@ -207,7 +207,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The maximum value in the sequence. public static Task> MaxAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -230,7 +230,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The minimum value in the sequence. public static Task> MinAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -252,7 +252,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -274,7 +274,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -296,7 +296,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -318,7 +318,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -340,7 +340,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -362,7 +362,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -384,7 +384,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -406,7 +406,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -428,7 +428,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -450,7 +450,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> AverageAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -472,7 +472,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -494,7 +494,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -516,7 +516,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -538,7 +538,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -560,7 +560,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -582,7 +582,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -604,7 +604,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -626,7 +626,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -648,7 +648,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -670,7 +670,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The average value in the sequence. public static Task> SumAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { @@ -693,7 +693,7 @@ namespace Microsoft.Azure.Cosmos.Linq /// The number of elements in the input sequence. public static Task> CountAsync( this IQueryable source, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (!(source.Provider is CosmosLinqQueryProvider cosmosLinqQueryProvider)) { diff --git a/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQueryProvider.cs b/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQueryProvider.cs index 3bf8b8cca..20db14c3d 100644 --- a/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQueryProvider.cs +++ b/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQueryProvider.cs @@ -110,7 +110,7 @@ namespace Microsoft.Azure.Cosmos.Linq public Task> ExecuteAggregateAsync( Expression expression, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { Type cosmosQueryType = typeof(CosmosLinqQuery).GetGenericTypeDefinition().MakeGenericType(typeof(TResult)); CosmosLinqQuery cosmosLINQQuery = (CosmosLinqQuery)Activator.CreateInstance( diff --git a/Microsoft.Azure.Cosmos/src/Linq/DocumentQueryProvider.cs b/Microsoft.Azure.Cosmos/src/Linq/DocumentQueryProvider.cs index ca8a2e09d..5a52d2f80 100644 --- a/Microsoft.Azure.Cosmos/src/Linq/DocumentQueryProvider.cs +++ b/Microsoft.Azure.Cosmos/src/Linq/DocumentQueryProvider.cs @@ -106,7 +106,7 @@ namespace Microsoft.Azure.Cosmos.Linq public async Task ExecuteAsync( Expression expression, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { Type documentQueryType = typeof(DocumentQuery).GetGenericTypeDefinition().MakeGenericType(typeof(TResult)); DocumentQuery documentQuery = (DocumentQuery)Activator.CreateInstance( @@ -129,6 +129,6 @@ namespace Microsoft.Azure.Cosmos.Linq { Task ExecuteAsync( Expression expression, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); } } diff --git a/Microsoft.Azure.Cosmos/src/PartitionKeyBuilder.cs b/Microsoft.Azure.Cosmos/src/PartitionKeyBuilder.cs index ee23816e9..9eacec15d 100644 --- a/Microsoft.Azure.Cosmos/src/PartitionKeyBuilder.cs +++ b/Microsoft.Azure.Cosmos/src/PartitionKeyBuilder.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Collections; using System.Collections.Generic; using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Routing; diff --git a/Microsoft.Azure.Cosmos/src/Patch/PatchOperationsJsonConverter.cs b/Microsoft.Azure.Cosmos/src/Patch/PatchOperationsJsonConverter.cs index 74a50ab27..0406c50ea 100644 --- a/Microsoft.Azure.Cosmos/src/Patch/PatchOperationsJsonConverter.cs +++ b/Microsoft.Azure.Cosmos/src/Patch/PatchOperationsJsonConverter.cs @@ -20,7 +20,10 @@ namespace Microsoft.Azure.Cosmos this.userSerializer = userSerializer ?? throw new ArgumentNullException(nameof(userSerializer)); } - public override bool CanConvert(Type objectType) => true; + public override bool CanConvert(Type objectType) + { + return true; + } public override bool CanRead => false; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/Collections/AsyncCollection.cs b/Microsoft.Azure.Cosmos/src/Query/Core/Collections/AsyncCollection.cs index 7cac09ca9..bdb056354 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/Collections/AsyncCollection.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/Collections/AsyncCollection.cs @@ -76,21 +76,9 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Collections throw new NotSupportedException($"The IProducerConsumerCollection type of {typeof(T)} is not supported."); } - public int Count - { - get - { - return this.collection.Count; - } - } + public int Count => this.collection.Count; - public bool IsUnbounded - { - get - { - return this.boundingCapacity >= int.MaxValue; - } - } + public bool IsUnbounded => this.boundingCapacity >= int.MaxValue; public async Task AddAsync(T item, CancellationToken token = default) { diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/Collections/PriorityQueue.cs b/Microsoft.Azure.Cosmos/src/Query/Core/Collections/PriorityQueue.cs index 9f541b930..fcab441ed 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/Collections/PriorityQueue.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/Collections/PriorityQueue.cs @@ -55,22 +55,13 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Collections this.Comparer = comparer ?? throw new ArgumentNullException(nameof(comparer)); } - public int Count - { - get - { - return this.queue.Count; - } - } + public int Count => this.queue.Count; public IComparer Comparer { get; } public bool IsSynchronized { get; } - public object SyncRoot - { - get { return this; } - } + public object SyncRoot => this; public void CopyTo(T[] array, int index) { diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ComparableTask/ComparableTask.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ComparableTask/ComparableTask.cs index 4b684d204..9c3ed13f9 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ComparableTask/ComparableTask.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ComparableTask/ComparableTask.cs @@ -36,7 +36,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ComparableTask public abstract bool Equals(IComparableTask other); - public override abstract int GetHashCode(); + public abstract override int GetHashCode(); protected int CompareToByPriority(ComparableTask other) { diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/CompositeContinuationToken.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/CompositeContinuationToken.cs index c8b947456..a7a51acab 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/CompositeContinuationToken.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/CompositeContinuationToken.cs @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens { using System.Collections.Generic; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; using Microsoft.Azure.Cosmos.Routing; @@ -52,7 +51,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens public static CosmosElement ToCosmosElement(CompositeContinuationToken compositeContinuationToken) { - CosmosElement token = compositeContinuationToken.Token == null ? (CosmosElement)CosmosNull.Create() : (CosmosElement)CosmosString.Create(compositeContinuationToken.Token); + CosmosElement token = compositeContinuationToken.Token == null ? CosmosNull.Create() : (CosmosElement)CosmosString.Create(compositeContinuationToken.Token); return CosmosObject.Create( new Dictionary() { diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/OrderByContinuationToken.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/OrderByContinuationToken.cs index 74cb8fc3f..efea0585f 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/OrderByContinuationToken.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/OrderByContinuationToken.cs @@ -221,7 +221,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens CosmosArray orderByItems = CosmosArray.Create(orderByItemsRaw); - CosmosElement filter = orderByContinuationToken.Filter == null ? (CosmosElement)CosmosNull.Create() : (CosmosElement)CosmosString.Create(orderByContinuationToken.Filter); + CosmosElement filter = orderByContinuationToken.Filter == null ? CosmosNull.Create() : (CosmosElement)CosmosString.Create(orderByContinuationToken.Filter); CosmosObject cosmosObject = CosmosObject.Create( new Dictionary() diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/PipelineContinuationTokenV1_1.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/PipelineContinuationTokenV1_1.cs index c2ab94920..0ba5aff32 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/PipelineContinuationTokenV1_1.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ContinuationTokens/PipelineContinuationTokenV1_1.cs @@ -58,7 +58,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens }, { PipelineContinuationTokenV1_1.QueryPlanPropertyName, - shouldSerializeQueryPlan ? (CosmosElement)CosmosString.Create(queryPlanString) : (CosmosElement)CosmosNull.Create() + shouldSerializeQueryPlan ? CosmosString.Create(queryPlanString) : (CosmosElement)CosmosNull.Create() }, { PipelineContinuationTokenV1_1.SourceContinuationTokenPropertyName, diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Client.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Client.cs index 3a807806b..3b5eb62ec 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Client.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Client.cs @@ -8,9 +8,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Diagnostics; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggregators; using Microsoft.Azure.Cosmos.Query.Core.Monads; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Compute.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Compute.cs index 5ba00a7fa..34a50f843 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Compute.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.Compute.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate { using System; using System.Collections.Generic; - using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.cs index e69a0ffac..70733c90e 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/AggregateDocumentQueryExecutionComponent.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggregators; using Microsoft.Azure.Cosmos.Query.Core.ExecutionContext; using Microsoft.Azure.Cosmos.Query.Core.Monads; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/AverageAggregator.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/AverageAggregator.cs index 1501e35d6..94f3da164 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/AverageAggregator.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/AverageAggregator.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega using System.Collections.Generic; using Microsoft.Azure.Cosmos.CosmosElements; using Microsoft.Azure.Cosmos.CosmosElements.Numbers; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; @@ -156,7 +155,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega } long count = Number64.ToLong(cosmosCount.Value); - + return TryCatch.FromResult(new AverageInfo(sum, count)); } @@ -205,7 +204,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega return null; } - return CosmosNumber64.Create(this.Sum.Value / (double)this.Count); + return CosmosNumber64.Create(this.Sum.Value / this.Count); } public override string ToString() diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/CountAggregator.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/CountAggregator.cs index 84851aaf6..f365d1d85 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/CountAggregator.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/CountAggregator.cs @@ -7,8 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega using System.Globalization; using Microsoft.Azure.Cosmos.CosmosElements; using Microsoft.Azure.Cosmos.CosmosElements.Numbers; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/IAggregator.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/IAggregator.cs index dace3bf6a..b1e878b12 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/IAggregator.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/IAggregator.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggregators { using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; /// /// Interface for all aggregators that are used to aggregate across continuation and partition boundaries. diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/MinMaxAggregator.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/MinMaxAggregator.cs index 5f77dbba7..92da8974e 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/MinMaxAggregator.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/MinMaxAggregator.cs @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega using System; using System.Collections.Generic; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.ExecutionContext.ItemProducers; using Microsoft.Azure.Cosmos.Query.Core.Monads; @@ -174,7 +173,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega } else { - globalMinMax = isMinAggregation ? (CosmosElement)ItemComparer.MaxValue : (CosmosElement)ItemComparer.MinValue; + globalMinMax = isMinAggregation ? ItemComparer.MaxValue : (CosmosElement)ItemComparer.MinValue; } return TryCatch.FromResult( @@ -332,10 +331,13 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega throw new ArgumentNullException(nameof(minMaxContinuationToken)); } - Dictionary dictionary = new Dictionary(); - dictionary.Add( - MinMaxContinuationToken.PropertyNames.Type, - EnumToCosmosString.ConvertEnumToCosmosString(minMaxContinuationToken.Type)); + Dictionary dictionary = new Dictionary + { + { + MinMaxContinuationToken.PropertyNames.Type, + EnumToCosmosString.ConvertEnumToCosmosString(minMaxContinuationToken.Type) + } + }; if (minMaxContinuationToken.Value != null) { dictionary.Add(MinMaxContinuationToken.PropertyNames.Value, minMaxContinuationToken.Value); diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SingleGroupAggregator.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SingleGroupAggregator.cs index 95a567226..9320cfffe 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SingleGroupAggregator.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SingleGroupAggregator.cs @@ -7,8 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega using System.Collections.Generic; using System.Linq; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; @@ -366,8 +364,10 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega public override CosmosElement GetCosmosElementContinuationToken() { - Dictionary dictionary = new Dictionary(); - dictionary.Add(nameof(this.initialized), CosmosBoolean.Create(this.initialized)); + Dictionary dictionary = new Dictionary + { + { nameof(this.initialized), CosmosBoolean.Create(this.initialized) } + }; if (this.value != null) { diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SumAggregator.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SumAggregator.cs index 433a3535c..31a74febf 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SumAggregator.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Aggregate/Aggregators/SumAggregator.cs @@ -7,8 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggrega using System.Globalization; using Microsoft.Azure.Cosmos.CosmosElements; using Microsoft.Azure.Cosmos.CosmosElements.Numbers; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/CosmosQueryExecutionComponent.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/CosmosQueryExecutionComponent.cs index 7ba532d49..963b86084 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/CosmosQueryExecutionComponent.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/CosmosQueryExecutionComponent.cs @@ -4,10 +4,8 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent { using System; - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; /// diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Client.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Client.cs index 56e54d82f..3a4ac0ee6 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Client.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Client.cs @@ -8,8 +8,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Distinct using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Compute.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Compute.cs index 89d931211..9cb62d439 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Compute.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.Compute.cs @@ -8,8 +8,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Distinct using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.cs index 09e35f81c..d47ec216a 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctDocumentQueryExecutionComponent.cs @@ -6,11 +6,8 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Distinct using System; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.ExecutionContext; using Microsoft.Azure.Cosmos.Query.Core.Monads; - using Newtonsoft.Json; /// /// Distinct queries return documents that are distinct with a page. diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.OrderedDistinctMap.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.OrderedDistinctMap.cs index da6e632d4..274cd87f8 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.OrderedDistinctMap.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.OrderedDistinctMap.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Distinct { using System; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Query.Core; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.UnorderedDistinctMap.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.UnorderedDistinctMap.cs index 9ff0e36f3..f74c7f6a4 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.UnorderedDistinctMap.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.UnorderedDistinctMap.cs @@ -10,8 +10,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Distinct using System.Text; using Microsoft.Azure.Cosmos.CosmosElements; using Microsoft.Azure.Cosmos.CosmosElements.Numbers; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; @@ -278,7 +276,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Distinct if (utf8Length <= UnorderdDistinctMap.UInt128Length) { Span utf8Buffer = stackalloc byte[UInt128Length]; - Encoding.UTF8.GetBytes(value, utf8Buffer); + Encoding.UTF8.GetBytes(value, utf8Buffer); if (utf8Length == 0) { added = this.AddSimpleValue(SimpleValues.EmptyString); diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.cs index 4267bc9ff..3c6829093 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/Distinct/DistinctMap.cs @@ -5,9 +5,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Distinct { using System; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Monads; /// diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/DocumentQueryExecutionComponentBase.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/DocumentQueryExecutionComponentBase.cs index e3ab5efd6..6ab10cb2a 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/DocumentQueryExecutionComponentBase.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/DocumentQueryExecutionComponentBase.cs @@ -33,13 +33,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent /// /// Gets a value indicating whether or not this component is done draining documents. /// - public virtual bool IsDone - { - get - { - return this.Source.IsDone; - } - } + public virtual bool IsDone => this.Source.IsDone; /// /// Disposes this context. diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.Compute.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.Compute.cs index e0dd91565..cf1b83ed9 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.Compute.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.Compute.cs @@ -5,12 +5,9 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.GroupBy { using System; using System.Collections.Generic; - using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate; using Microsoft.Azure.Cosmos.Query.Core.Metrics; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.cs index d3aeb0157..43c92b173 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/GroupBy/GroupByDocumentQueryExecutionComponent.cs @@ -9,8 +9,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.GroupBy using System.Linq; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate; using Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.Aggregate.Aggregators; @@ -159,7 +157,10 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.GroupBy } } - public bool TryGetPayload(out CosmosElement payload) => this.cosmosObject.TryGetValue(PayloadPropertyName, out payload); + public bool TryGetPayload(out CosmosElement payload) + { + return this.cosmosObject.TryGetValue(PayloadPropertyName, out payload); + } } protected sealed class GroupingTable : IEnumerable> @@ -301,9 +302,15 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.GroupBy return TryCatch.FromResult(groupingTable); } - IEnumerator> IEnumerable>.GetEnumerator() => this.table.GetEnumerator(); + IEnumerator> IEnumerable>.GetEnumerator() + { + return this.table.GetEnumerator(); + } - IEnumerator IEnumerable.GetEnumerator() => this.table.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + { + return this.table.GetEnumerator(); + } } } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/IDocumentQueryExecutionComponent.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/IDocumentQueryExecutionComponent.cs index eb547dad6..628f06d49 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/IDocumentQueryExecutionComponent.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/IDocumentQueryExecutionComponent.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; /// diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.Compute.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.Compute.cs index 7479565e4..ab26bbf84 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.Compute.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.Compute.cs @@ -6,16 +6,13 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.SkipTake using System; using System.Collections.Generic; using System.Linq; - using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; using Microsoft.Azure.Cosmos.CosmosElements.Numbers; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.Monads; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; - using Microsoft.Azure.Documents; internal abstract partial class SkipDocumentQueryExecutionComponent : DocumentQueryExecutionComponentBase { diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.cs index 0153f6a1e..df2766ebc 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/SkipDocumentQueryExecutionComponent.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.SkipTake using System; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Query.Core.ContinuationTokens; using Microsoft.Azure.Cosmos.Query.Core.ExecutionContext; using Microsoft.Azure.Cosmos.Query.Core.Monads; @@ -56,12 +55,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.SkipTake return tryCreate; } - public override bool IsDone - { - get - { - return this.Source.IsDone; - } - } + public override bool IsDone => this.Source.IsDone; } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/TakeDocumentQueryExecutionComponent.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/TakeDocumentQueryExecutionComponent.cs index 48a76be5f..9db4b911f 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/TakeDocumentQueryExecutionComponent.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionComponent/SkipTake/TakeDocumentQueryExecutionComponent.cs @@ -81,12 +81,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionComponent.SkipTake return tryCreateComponentAsync; } - public override bool IsDone - { - get - { - return this.Source.IsDone || this.takeCount <= 0; - } - } + public override bool IsDone => this.Source.IsDone || this.takeCount <= 0; } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CatchAllCosmosQueryExecutionContext.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CatchAllCosmosQueryExecutionContext.cs index e37a658f4..e329905fd 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CatchAllCosmosQueryExecutionContext.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CatchAllCosmosQueryExecutionContext.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; internal sealed class CatchAllCosmosQueryExecutionContext : CosmosQueryExecutionContext diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosCrossPartitionQueryExecutionContext.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosCrossPartitionQueryExecutionContext.cs index f295f7d45..4155e6c06 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosCrossPartitionQueryExecutionContext.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosCrossPartitionQueryExecutionContext.cs @@ -101,7 +101,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext /// but we eventually used the whole page for the next continuation; which continuation reports the cost? /// Basically the only thing we can ensure is if you drain a query fully you should get back the same query metrics by the end. /// - private ConcurrentBag diagnosticsPages; + private readonly ConcurrentBag diagnosticsPages; /// /// Total number of buffered items to determine if we can go for another prefetch while still honoring the MaxBufferedItemCount. @@ -364,7 +364,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext querySpecForInit, partitionKeyRange, this.OnItemProducerTreeCompleteFetching, - this.itemProducerForest.Comparer as IComparer, + this.itemProducerForest.Comparer, this.equalityComparer, this.testSettings, deferFirstPage, diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContext.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContext.cs index 1cc7f29ab..e0cee1aea 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContext.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContext.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; /// diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContextWithNameCacheStaleRetry.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContextWithNameCacheStaleRetry.cs index 5153fb290..900481429 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContextWithNameCacheStaleRetry.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/CosmosQueryExecutionContextWithNameCacheStaleRetry.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; internal sealed class CosmosQueryExecutionContextWithNameCacheStaleRetry : CosmosQueryExecutionContext diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducer.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducer.cs index af5d8a9c8..f3b46d8f9 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducer.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducer.cs @@ -7,15 +7,11 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext.ItemProducers using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Cosmos.Query.Core; using Microsoft.Azure.Cosmos.Query.Core.Collections; - using Microsoft.Azure.Cosmos.Query.Core.Metrics; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; using Microsoft.Azure.Cosmos.Resource.CosmosExceptions; - using Microsoft.Azure.Documents; using PartitionKeyRange = Documents.PartitionKeyRange; using PartitionKeyRangeIdentity = Documents.PartitionKeyRangeIdentity; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducerTree.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducerTree.cs index e70805add..d4622c3f5 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducerTree.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/ItemProducers/ItemProducerTree.cs @@ -12,7 +12,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext.ItemProducers using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Cosmos.Query.Core; using Microsoft.Azure.Cosmos.Query.Core.Collections; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/LazyCosmosQueryExecutionContext.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/LazyCosmosQueryExecutionContext.cs index 1e7c61a02..55480bad9 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/LazyCosmosQueryExecutionContext.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/LazyCosmosQueryExecutionContext.cs @@ -5,12 +5,9 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext { using System; - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Diagnostics; - using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Query.Core.Monads; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/OrderBy/CosmosElementToQueryLiteral.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/OrderBy/CosmosElementToQueryLiteral.cs index 68eb12530..107f538f2 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/OrderBy/CosmosElementToQueryLiteral.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/OrderBy/CosmosElementToQueryLiteral.cs @@ -45,7 +45,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext.OrderBy { this.stringBuilder.AppendFormat( "C_Binary(\"0x{0}\")", - PartitionKeyInternal.HexConvert.ToHex(cosmosBinary.Value.ToArray(), start: 0, length: (int)cosmosBinary.Value.Length)); + PartitionKeyInternal.HexConvert.ToHex(cosmosBinary.Value.ToArray(), start: 0, length: cosmosBinary.Value.Length)); } public void Visit(CosmosBoolean cosmosBoolean) diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/CosmosParallelItemQueryExecutionContext.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/CosmosParallelItemQueryExecutionContext.cs index 56a2f6225..adf1c7189 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/CosmosParallelItemQueryExecutionContext.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/CosmosParallelItemQueryExecutionContext.cs @@ -29,7 +29,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext.Parallel private static readonly Func FetchPriorityFunction = documentProducerTree => int.Parse(documentProducerTree.PartitionKeyRange.Id); private readonly bool returnResultsInDeterministicOrder; - + /// /// Initializes a new instance of the CosmosParallelItemQueryExecutionContext class. /// diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/NonDeterministicParallelItemProducerTreeComparer.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/NonDeterministicParallelItemProducerTreeComparer.cs index 632fa7232..f058664d0 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/NonDeterministicParallelItemProducerTreeComparer.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/Parallel/NonDeterministicParallelItemProducerTreeComparer.cs @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext.Parallel using System; using System.Collections.Generic; using Microsoft.Azure.Cosmos.Query.Core.ExecutionContext.ItemProducers; - using PartitionKeyRange = Documents.PartitionKeyRange; /// /// Implementation of that returns documents from the partition that has the most documents buffered first. diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/PipelinedDocumentQueryExecutionContext.cs b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/PipelinedDocumentQueryExecutionContext.cs index 83ebb489e..15edbc3aa 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/PipelinedDocumentQueryExecutionContext.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/ExecutionContext/PipelinedDocumentQueryExecutionContext.cs @@ -112,13 +112,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.ExecutionContext /// /// Gets a value indicating whether this execution context is done draining documents. /// - public override bool IsDone - { - get - { - return this.component.IsDone; - } - } + public override bool IsDone => this.component.IsDone; public static async Task> TryCreateAsync( ExecutionEnvironment executionEnvironment, diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/PartitionedQueryMetrics.cs b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/PartitionedQueryMetrics.cs index 9b83b8256..1339333b0 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/PartitionedQueryMetrics.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/PartitionedQueryMetrics.cs @@ -50,48 +50,24 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics /// /// Gets the count. /// - public int Count - { - get - { - return this.partitionedQueryMetrics.Count; - } - } + public int Count => this.partitionedQueryMetrics.Count; /// /// Gets the keys. /// - public IEnumerable Keys - { - get - { - return this.partitionedQueryMetrics.Keys; - } - } + public IEnumerable Keys => this.partitionedQueryMetrics.Keys; /// /// Gets the values. /// - public IEnumerable Values - { - get - { - return this.partitionedQueryMetrics.Values; - } - } + public IEnumerable Values => this.partitionedQueryMetrics.Values; /// /// Gets the QueryMetrics corresponding to the key. /// /// The partition id. /// The QueryMetrics corresponding to the key. - public QueryMetrics this[string key] - { - get - { - return this.partitionedQueryMetrics[key]; - } - } + public QueryMetrics this[string key] => this.partitionedQueryMetrics[key]; /// /// Aggregates an IEnumerable of partitioned query metrics together. diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsTextWriter.cs b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsTextWriter.cs index f6846db7d..c85423b1b 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsTextWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsTextWriter.cs @@ -158,71 +158,104 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics // Do Nothing } - protected override void WriteRetrievedDocumentCount(long retrievedDocumentCount) => QueryMetricsTextWriter.AppendCountToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.RetrievedDocumentCount, - retrievedDocumentCount, - indentLevel: 0); + protected override void WriteRetrievedDocumentCount(long retrievedDocumentCount) + { + QueryMetricsTextWriter.AppendCountToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.RetrievedDocumentCount, +retrievedDocumentCount, +indentLevel: 0); + } - protected override void WriteRetrievedDocumentSize(long retrievedDocumentSize) => QueryMetricsTextWriter.AppendBytesToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.RetrievedDocumentSize, - retrievedDocumentSize, - indentLevel: 0); + protected override void WriteRetrievedDocumentSize(long retrievedDocumentSize) + { + QueryMetricsTextWriter.AppendBytesToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.RetrievedDocumentSize, +retrievedDocumentSize, +indentLevel: 0); + } - protected override void WriteOutputDocumentCount(long outputDocumentCount) => QueryMetricsTextWriter.AppendCountToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.OutputDocumentCount, - outputDocumentCount, - indentLevel: 0); + protected override void WriteOutputDocumentCount(long outputDocumentCount) + { + QueryMetricsTextWriter.AppendCountToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.OutputDocumentCount, +outputDocumentCount, +indentLevel: 0); + } - protected override void WriteOutputDocumentSize(long outputDocumentSize) => QueryMetricsTextWriter.AppendBytesToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.OutputDocumentSize, - outputDocumentSize, - indentLevel: 0); + protected override void WriteOutputDocumentSize(long outputDocumentSize) + { + QueryMetricsTextWriter.AppendBytesToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.OutputDocumentSize, +outputDocumentSize, +indentLevel: 0); + } - protected override void WriteIndexHitRatio(double indexHitRatio) => QueryMetricsTextWriter.AppendPercentageToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.IndexUtilization, - indexHitRatio, - indentLevel: 0); + protected override void WriteIndexHitRatio(double indexHitRatio) + { + QueryMetricsTextWriter.AppendPercentageToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.IndexUtilization, +indexHitRatio, +indentLevel: 0); + } - protected override void WriteTotalQueryExecutionTime(TimeSpan totalQueryExecutionTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.TotalQueryExecutionTime, - totalQueryExecutionTime, - indentLevel: 0); + protected override void WriteTotalQueryExecutionTime(TimeSpan totalQueryExecutionTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.TotalQueryExecutionTime, +totalQueryExecutionTime, +indentLevel: 0); + } #region QueryPreparationTimes - protected override void WriteBeforeQueryPreparationTimes() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.QueryPreparationTimes, - indentLevel: 1); + protected override void WriteBeforeQueryPreparationTimes() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.QueryPreparationTimes, +indentLevel: 1); + } - protected override void WriteQueryCompilationTime(TimeSpan queryCompilationTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.QueryCompileTime, - queryCompilationTime, - indentLevel: 2); + protected override void WriteQueryCompilationTime(TimeSpan queryCompilationTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.QueryCompileTime, +queryCompilationTime, +indentLevel: 2); + } - protected override void WriteLogicalPlanBuildTime(TimeSpan logicalPlanBuildTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.LogicalPlanBuildTime, - logicalPlanBuildTime, - indentLevel: 2); + protected override void WriteLogicalPlanBuildTime(TimeSpan logicalPlanBuildTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.LogicalPlanBuildTime, +logicalPlanBuildTime, +indentLevel: 2); + } - protected override void WritePhysicalPlanBuildTime(TimeSpan physicalPlanBuildTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.PhysicalPlanBuildTime, - physicalPlanBuildTime, - indentLevel: 2); + protected override void WritePhysicalPlanBuildTime(TimeSpan physicalPlanBuildTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.PhysicalPlanBuildTime, +physicalPlanBuildTime, +indentLevel: 2); + } - protected override void WriteQueryOptimizationTime(TimeSpan queryOptimizationTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.QueryOptimizationTime, - queryOptimizationTime, - indentLevel: 2); + protected override void WriteQueryOptimizationTime(TimeSpan queryOptimizationTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.QueryOptimizationTime, +queryOptimizationTime, +indentLevel: 2); + } protected override void WriteAfterQueryPreparationTimes() { @@ -230,17 +263,23 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics } #endregion - protected override void WriteIndexLookupTime(TimeSpan indexLookupTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.IndexLookupTime, - indexLookupTime, - indentLevel: 1); + protected override void WriteIndexLookupTime(TimeSpan indexLookupTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.IndexLookupTime, +indexLookupTime, +indentLevel: 1); + } - protected override void WriteDocumentLoadTime(TimeSpan documentLoadTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.DocumentLoadTime, - documentLoadTime, - indentLevel: 1); + protected override void WriteDocumentLoadTime(TimeSpan documentLoadTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.DocumentLoadTime, +documentLoadTime, +indentLevel: 1); + } protected override void WriteVMExecutionTime(TimeSpan vmExecutionTime) { @@ -248,28 +287,40 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics } #region RuntimeExecutionTimes - protected override void WriteBeforeRuntimeExecutionTimes() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.RuntimeExecutionTimes, - indentLevel: 1); + protected override void WriteBeforeRuntimeExecutionTimes() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.RuntimeExecutionTimes, +indentLevel: 1); + } - protected override void WriteQueryEngineExecutionTime(TimeSpan queryEngineExecutionTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.QueryEngineTimes, - queryEngineExecutionTime, - indentLevel: 2); + protected override void WriteQueryEngineExecutionTime(TimeSpan queryEngineExecutionTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.QueryEngineTimes, +queryEngineExecutionTime, +indentLevel: 2); + } - protected override void WriteSystemFunctionExecutionTime(TimeSpan systemFunctionExecutionTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.SystemFunctionExecuteTime, - systemFunctionExecutionTime, - indentLevel: 2); + protected override void WriteSystemFunctionExecutionTime(TimeSpan systemFunctionExecutionTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.SystemFunctionExecuteTime, +systemFunctionExecutionTime, +indentLevel: 2); + } - protected override void WriteUserDefinedFunctionExecutionTime(TimeSpan userDefinedFunctionExecutionTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.UserDefinedFunctionExecutionTime, - userDefinedFunctionExecutionTime, - indentLevel: 2); + protected override void WriteUserDefinedFunctionExecutionTime(TimeSpan userDefinedFunctionExecutionTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.UserDefinedFunctionExecutionTime, +userDefinedFunctionExecutionTime, +indentLevel: 2); + } protected override void WriteAfterRuntimeExecutionTimes() { @@ -277,29 +328,41 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics } #endregion - protected override void WriteDocumentWriteTime(TimeSpan documentWriteTime) => QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.DocumentWriteTime, - documentWriteTime, - indentLevel: 1); + protected override void WriteDocumentWriteTime(TimeSpan documentWriteTime) + { + QueryMetricsTextWriter.AppendTimeSpanToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.DocumentWriteTime, +documentWriteTime, +indentLevel: 1); + } #region ClientSideMetrics - protected override void WriteBeforeClientSideMetrics() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.ClientSideQueryMetrics, - indentLevel: 0); + protected override void WriteBeforeClientSideMetrics() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.ClientSideQueryMetrics, +indentLevel: 0); + } - protected override void WriteRetries(long retries) => QueryMetricsTextWriter.AppendCountToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.Retries, - retries, - indentLevel: 1); + protected override void WriteRetries(long retries) + { + QueryMetricsTextWriter.AppendCountToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.Retries, +retries, +indentLevel: 1); + } - protected override void WriteRequestCharge(double requestCharge) => QueryMetricsTextWriter.AppendRUToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.RequestCharge, - requestCharge, - indentLevel: 1); + protected override void WriteRequestCharge(double requestCharge) + { + QueryMetricsTextWriter.AppendRUToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.RequestCharge, +requestCharge, +indentLevel: 1); + } protected override void WriteBeforePartitionExecutionTimeline() { @@ -347,22 +410,28 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics this.lastFetchRetryCount = retryCount; } - protected override void WriteAfterFetchExecutionRange() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - PartitionExecutionTimelineTable.GetRow( - this.lastFetchPartitionId, - this.lastActivityId, - this.lastStartTime.ToUniversalTime().ToString(DateTimeFormat), - this.lastEndTime.ToUniversalTime().ToString(DateTimeFormat), - (this.lastEndTime - this.lastStartTime).TotalMilliseconds.ToString("0.00"), - this.lastFetchDocumentCount, - this.lastFetchRetryCount), - indentLevel: 1); + protected override void WriteAfterFetchExecutionRange() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +PartitionExecutionTimelineTable.GetRow( +this.lastFetchPartitionId, +this.lastActivityId, +this.lastStartTime.ToUniversalTime().ToString(DateTimeFormat), +this.lastEndTime.ToUniversalTime().ToString(DateTimeFormat), +(this.lastEndTime - this.lastStartTime).TotalMilliseconds.ToString("0.00"), +this.lastFetchDocumentCount, +this.lastFetchRetryCount), +indentLevel: 1); + } - protected override void WriteAfterPartitionExecutionTimeline() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - PartitionExecutionTimelineTable.BottomLine, - indentLevel: 1); + protected override void WriteAfterPartitionExecutionTimeline() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +PartitionExecutionTimelineTable.BottomLine, +indentLevel: 1); + } protected override void WriteBeforeSchedulingMetrics() { @@ -410,21 +479,27 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics this.lastNumberOfPreemptions = numPreemptions; } - protected override void WriteAfterPartitionSchedulingTimeSpan() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - SchedulingMetricsTable.GetRow( - this.lastSchedulingPartitionId, - this.lastResponseTime.TotalMilliseconds.ToString("0.00"), - this.lastRunTime.TotalMilliseconds.ToString("0.00"), - this.lastWaitTime.TotalMilliseconds.ToString("0.00"), - this.lastTurnaroundTime.TotalMilliseconds.ToString("0.00"), - this.lastNumberOfPreemptions), - indentLevel: 1); + protected override void WriteAfterPartitionSchedulingTimeSpan() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +SchedulingMetricsTable.GetRow( +this.lastSchedulingPartitionId, +this.lastResponseTime.TotalMilliseconds.ToString("0.00"), +this.lastRunTime.TotalMilliseconds.ToString("0.00"), +this.lastWaitTime.TotalMilliseconds.ToString("0.00"), +this.lastTurnaroundTime.TotalMilliseconds.ToString("0.00"), +this.lastNumberOfPreemptions), +indentLevel: 1); + } - protected override void WriteAfterSchedulingMetrics() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - SchedulingMetricsTable.BottomLine, - indentLevel: 1); + protected override void WriteAfterSchedulingMetrics() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +SchedulingMetricsTable.BottomLine, +indentLevel: 1); + } protected override void WriteAfterClientSideMetrics() { @@ -433,10 +508,13 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics #endregion #region IndexUtilizationInfo - protected override void WriteBeforeIndexUtilizationInfo() => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - this.stringBuilder, - QueryMetricsTextWriter.IndexUtilizationInfo, - indentLevel: 0); + protected override void WriteBeforeIndexUtilizationInfo() + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +this.stringBuilder, +QueryMetricsTextWriter.IndexUtilizationInfo, +indentLevel: 0); + } protected override void WriteIndexUtilizationInfo(IndexUtilizationInfo indexUtilizationInfo) { @@ -567,10 +645,13 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics indentLevel); } - private static void AppendNewlineToStringBuilder(StringBuilder stringBuilder) => QueryMetricsTextWriter.AppendHeaderToStringBuilder( - stringBuilder, - string.Empty, - indentLevel: 0); + private static void AppendNewlineToStringBuilder(StringBuilder stringBuilder) + { + QueryMetricsTextWriter.AppendHeaderToStringBuilder( +stringBuilder, +string.Empty, +indentLevel: 0); + } #endregion } } diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsWriter.cs b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsWriter.cs index b657e958c..d15b169d3 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/QueryMetricsWriter.cs @@ -68,7 +68,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics protected abstract void WriteTotalQueryExecutionTime(TimeSpan totalQueryExecutionTime); -#region QueryPreparationTimes + #region QueryPreparationTimes private void WriteQueryPreparationTimes(QueryPreparationTimes queryPreparationTimes) { this.WriteBeforeQueryPreparationTimes(); @@ -92,7 +92,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics protected abstract void WriteQueryOptimizationTime(TimeSpan queryOptimizationTime); protected abstract void WriteAfterQueryPreparationTimes(); -#endregion + #endregion protected abstract void WriteIndexLookupTime(TimeSpan indexLookupTime); @@ -100,7 +100,7 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics protected abstract void WriteVMExecutionTime(TimeSpan vMExecutionTime); -#region RuntimeExecutionTimes + #region RuntimeExecutionTimes private void WriteRuntimesExecutionTimes(RuntimeExecutionTimes runtimeExecutionTimes) { this.WriteBeforeRuntimeExecutionTimes(); @@ -121,11 +121,11 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics protected abstract void WriteUserDefinedFunctionExecutionTime(TimeSpan userDefinedFunctionExecutionTime); protected abstract void WriteAfterRuntimeExecutionTimes(); -#endregion + #endregion protected abstract void WriteDocumentWriteTime(TimeSpan documentWriteTime); -#region ClientSideMetrics + #region ClientSideMetrics private void WriteClientSideMetrics(ClientSideMetrics clientSideMetrics) { this.WriteBeforeClientSideMetrics(); @@ -224,16 +224,16 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics protected abstract void WriteAfterSchedulingMetrics(); protected abstract void WriteAfterClientSideMetrics(); -#endregion + #endregion -#region IndexUtilizationInfo + #region IndexUtilizationInfo protected abstract void WriteBeforeIndexUtilizationInfo(); protected abstract void WriteIndexUtilizationInfo(IndexUtilizationInfo indexUtilizationInfo); protected abstract void WriteAfterIndexUtilizationInfo(); -#endregion + #endregion protected abstract void WriteAfterQueryMetrics(); } diff --git a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/RuntimeExecutionTimes.cs b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/RuntimeExecutionTimes.cs index 82f7aa57d..0fd8dc22f 100644 --- a/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/RuntimeExecutionTimes.cs +++ b/Microsoft.Azure.Cosmos/src/Query/Core/Metrics/RuntimeExecutionTimes.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Metrics { using System; - using System.Collections.Generic; /// /// Query runtime execution times in the Azure Cosmos DB service. diff --git a/Microsoft.Azure.Cosmos/src/Query/v2Query/DocumentQueryExecutionContextFactory.cs b/Microsoft.Azure.Cosmos/src/Query/v2Query/DocumentQueryExecutionContextFactory.cs index fa3fea2b0..77e14a0b8 100644 --- a/Microsoft.Azure.Cosmos/src/Query/v2Query/DocumentQueryExecutionContextFactory.cs +++ b/Microsoft.Azure.Cosmos/src/Query/v2Query/DocumentQueryExecutionContextFactory.cs @@ -5,8 +5,6 @@ namespace Microsoft.Azure.Cosmos.Query { using System; using System.Collections.Generic; - using System.Diagnostics; - using System.Globalization; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; diff --git a/Microsoft.Azure.Cosmos/src/Query/v2Query/IDocumentQuery.cs b/Microsoft.Azure.Cosmos/src/Query/v2Query/IDocumentQuery.cs index b6b67e1b6..d2c81087e 100644 --- a/Microsoft.Azure.Cosmos/src/Query/v2Query/IDocumentQuery.cs +++ b/Microsoft.Azure.Cosmos/src/Query/v2Query/IDocumentQuery.cs @@ -39,13 +39,13 @@ namespace Microsoft.Azure.Cosmos.Linq /// The type of the object returned in the query result. /// (Optional) The allows for notification that operations should be cancelled. /// The Task object for the asynchronous response from query execution. - Task> ExecuteNextAsync(CancellationToken token = default(CancellationToken)); + Task> ExecuteNextAsync(CancellationToken token = default); /// /// Executes the query and retrieves the next page of results as dynamic objects in the Azure Cosmos DB service. /// /// (Optional) The allows for notification that operations should be cancelled. /// The Task object for the asynchronous response from query execution. - Task> ExecuteNextAsync(CancellationToken token = default(CancellationToken)); + Task> ExecuteNextAsync(CancellationToken token = default); } } diff --git a/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryIterator.cs b/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryIterator.cs index 9c18f7c67..402c9bdc4 100644 --- a/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryIterator.cs +++ b/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryIterator.cs @@ -5,11 +5,9 @@ namespace Microsoft.Azure.Cosmos.Query { using System; - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Cosmos.Query.Core; using Microsoft.Azure.Cosmos.Query.Core.Exceptions; using Microsoft.Azure.Cosmos.Query.Core.ExecutionContext; diff --git a/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs b/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs index e419f47af..6a69e49cd 100644 --- a/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs @@ -6,12 +6,9 @@ namespace Microsoft.Azure.Cosmos using System; using System.Collections.Generic; using System.IO; - using System.Linq; using System.Net; using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Query; using Microsoft.Azure.Cosmos.Serializer; - using Microsoft.Azure.Documents; /// /// Represents the template class used by feed methods (enumeration operations) for the Azure Cosmos DB service. @@ -61,13 +58,7 @@ namespace Microsoft.Azure.Cosmos public int Count { get; } - public override Stream Content - { - get - { - return this.memoryStream?.Value; - } - } + public override Stream Content => this.memoryStream?.Value; internal virtual IReadOnlyList CosmosElements { get; } diff --git a/Microsoft.Azure.Cosmos/src/RequestOptions/QueryRequestOptions.cs b/Microsoft.Azure.Cosmos/src/RequestOptions/QueryRequestOptions.cs index 2bc739ff7..40a0eeaa9 100644 --- a/Microsoft.Azure.Cosmos/src/RequestOptions/QueryRequestOptions.cs +++ b/Microsoft.Azure.Cosmos/src/RequestOptions/QueryRequestOptions.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Globalization; using System.Text; using Microsoft.Azure.Cosmos.CosmosElements; using Microsoft.Azure.Cosmos.Query.Core; diff --git a/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs b/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs index 582197df4..66ce77195 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Cosmos using System.Diagnostics; using System.IO; using System.Net.Http; - using System.Net.Http.Headers; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictResourceTypeJsonConverter.cs b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictResourceTypeJsonConverter.cs index 037caa551..7f2f00f07 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictResourceTypeJsonConverter.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictResourceTypeJsonConverter.cs @@ -33,7 +33,7 @@ namespace Microsoft.Azure.Cosmos } else { - throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, "Unsupported resource type {0}", value.ToString())); + throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "Unsupported resource type {0}", value.ToString())); } writer.WriteValue(resourceType); @@ -72,6 +72,9 @@ namespace Microsoft.Azure.Cosmos public override bool CanRead => true; - public override bool CanConvert(Type objectType) => true; + public override bool CanConvert(Type objectType) + { + return true; + } } } diff --git a/Microsoft.Azure.Cosmos/src/Resource/Conflict/Conflicts.cs b/Microsoft.Azure.Cosmos/src/Resource/Conflict/Conflicts.cs index ca30a3a01..a6e18c4c0 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Conflict/Conflicts.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Conflict/Conflicts.cs @@ -24,7 +24,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task DeleteAsync( ConflictProperties conflict, PartitionKey partitionKey, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Reads the item that originated the conflict. @@ -55,7 +55,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task> ReadCurrentAsync( ConflictProperties conflict, PartitionKey partitionKey, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Reads the content of the Conflict resource in the Azure Cosmos DB service. diff --git a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs index 893f4a1e8..33afc5941 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs @@ -39,7 +39,7 @@ namespace Microsoft.Azure.Cosmos CosmosDiagnosticsContext diagnosticsContext, ConflictProperties conflict, PartitionKey partitionKey, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (conflict == null) { @@ -135,7 +135,7 @@ namespace Microsoft.Azure.Cosmos CosmosDiagnosticsContext diagnosticsContext, ConflictProperties cosmosConflict, PartitionKey partitionKey, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (cosmosConflict == null) { @@ -199,7 +199,7 @@ namespace Microsoft.Azure.Cosmos } } - return default(T); + return default; } } } diff --git a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsInlineCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsInlineCore.cs index ea24486f4..12450c7b6 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsInlineCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsInlineCore.cs @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Cosmos public override Task DeleteAsync( ConflictProperties conflict, PartitionKey partitionKey, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ClientContext.OperationHelperAsync( operationName: nameof(DeleteAsync), @@ -77,7 +77,7 @@ namespace Microsoft.Azure.Cosmos public override Task> ReadCurrentAsync( ConflictProperties cosmosConflict, PartitionKey partitionKey, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ClientContext.OperationHelperAsync( operationName: nameof(ReadCurrentAsync), diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs index e67296fdd..4ca8fd711 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Cosmos using System.Linq; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos.Query; /// /// Operations for reading, replacing, or deleting a specific, existing container or item in a container by id. @@ -66,7 +65,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task ReadContainerAsync( ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Reads a from the Azure Cosmos service as an asynchronous operation. @@ -87,7 +86,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task ReadContainerStreamAsync( ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replace a from the Azure Cosmos service as an asynchronous operation. @@ -113,7 +112,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReplaceContainerAsync( ContainerProperties containerProperties, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replace a from the Azure Cosmos service as an asynchronous operation. @@ -137,7 +136,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReplaceContainerStreamAsync( ContainerProperties containerProperties, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos DB service as an asynchronous operation. @@ -156,7 +155,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task DeleteContainerAsync( ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos DB service as an asynchronous operation. @@ -175,7 +174,7 @@ namespace Microsoft.Azure.Cosmos /// A containing a which will contain information about the request issued. public abstract Task DeleteContainerStreamAsync( ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Gets container throughput in measurement of request units per second in the Azure Cosmos service. @@ -202,7 +201,7 @@ namespace Microsoft.Azure.Cosmos /// Request Units /// Set throughput on a container public abstract Task ReadThroughputAsync( - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Gets container throughput in measurement of request units per second in the Azure Cosmos service. @@ -240,7 +239,7 @@ namespace Microsoft.Azure.Cosmos /// Set throughput on a container public abstract Task ReadThroughputAsync( RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Sets throughput provisioned for a container in measurement of request units per second in the Azure Cosmos service. @@ -266,7 +265,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReplaceThroughputAsync( int throughput, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Sets throughput provisioned for a container in measurement of request units per second in the Azure Cosmos service. @@ -301,7 +300,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReplaceThroughputAsync( ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a Item as an asynchronous operation in the Azure Cosmos service. @@ -344,7 +343,7 @@ namespace Microsoft.Azure.Cosmos Stream streamPayload, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a item as an asynchronous operation in the Azure Cosmos service. @@ -377,7 +376,7 @@ namespace Microsoft.Azure.Cosmos T item, PartitionKey? partitionKey = null, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Reads a item from the Azure Cosmos service as an asynchronous operation. @@ -422,7 +421,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Reads a item from the Azure Cosmos service as an asynchronous operation. @@ -458,7 +457,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Upserts an item stream as an asynchronous operation in the Azure Cosmos service. @@ -504,7 +503,7 @@ namespace Microsoft.Azure.Cosmos Stream streamPayload, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Upserts an item as an asynchronous operation in the Azure Cosmos service. @@ -537,7 +536,7 @@ namespace Microsoft.Azure.Cosmos T item, PartitionKey? partitionKey = null, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replaces a item in the Azure Cosmos service as an asynchronous operation. @@ -589,7 +588,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replaces a item in the Azure Cosmos service as an asynchronous operation. @@ -630,7 +629,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey? partitionKey = null, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); #if INTERNAL /// @@ -692,7 +691,7 @@ namespace Microsoft.Azure.Cosmos PartitionKey partitionKey, IReadOnlyList patchOperations, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Patches an item in the Azure Cosmos service as an asynchronous operation. @@ -724,7 +723,7 @@ namespace Microsoft.Azure.Cosmos PartitionKey partitionKey, IReadOnlyList patchOperations, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); #endif /// @@ -760,7 +759,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a item from the Azure Cosmos service as an asynchronous operation. @@ -787,7 +786,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. @@ -1170,7 +1169,7 @@ namespace Microsoft.Azure.Cosmos /// (Optional) representing request cancellation. /// A list of . /// https://aka.ms/cosmosdb-dot-net-exceptions#typed-api - public abstract Task> GetFeedRangesAsync(CancellationToken cancellationToken = default(CancellationToken)); + public abstract Task> GetFeedRangesAsync(CancellationToken cancellationToken = default); /// /// This method creates an iterator to consume a Change Feed. @@ -1266,7 +1265,7 @@ namespace Microsoft.Azure.Cosmos /// https://aka.ms/cosmosdb-dot-net-exceptions#typed-api public abstract Task> GetPartitionKeyRangesAsync( FeedRange feedRange, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs index 43ab14a52..2b03ca035 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs @@ -45,7 +45,7 @@ namespace Microsoft.Azure.Cosmos Stream streamPayload, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return await this.ProcessItemStreamAsync( partitionKey: partitionKey, @@ -62,7 +62,7 @@ namespace Microsoft.Azure.Cosmos T item, PartitionKey? partitionKey = null, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (item == null) { @@ -86,7 +86,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return await this.ProcessItemStreamAsync( partitionKey: partitionKey, @@ -103,7 +103,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { ResponseMessage response = await this.ProcessItemStreamAsync( partitionKey: partitionKey, @@ -122,7 +122,7 @@ namespace Microsoft.Azure.Cosmos Stream streamPayload, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return await this.ProcessItemStreamAsync( partitionKey: partitionKey, @@ -139,7 +139,7 @@ namespace Microsoft.Azure.Cosmos T item, PartitionKey? partitionKey = null, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (item == null) { @@ -164,7 +164,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return await this.ProcessItemStreamAsync( partitionKey: partitionKey, @@ -182,7 +182,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey? partitionKey = null, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (id == null) { @@ -211,7 +211,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return await this.ProcessItemStreamAsync( partitionKey: partitionKey, @@ -228,7 +228,7 @@ namespace Microsoft.Azure.Cosmos string id, PartitionKey partitionKey, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { ResponseMessage response = await this.ProcessItemStreamAsync( partitionKey: partitionKey, @@ -281,7 +281,7 @@ namespace Microsoft.Azure.Cosmos string continuationToken, FeedRangeInternal feedRangeInternal, QueryRequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (queryDefinition == null) { @@ -527,7 +527,7 @@ namespace Microsoft.Azure.Cosmos return new BatchCore(this, partitionKey); } - public override async Task> GetChangeFeedTokensAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override async Task> GetChangeFeedTokensAsync(CancellationToken cancellationToken = default) { Routing.PartitionKeyRangeCache pkRangeCache = await this.ClientContext.DocumentClient.GetPartitionKeyRangeCacheAsync(); string containerRid = await this.GetRIDAsync(cancellationToken); @@ -547,7 +547,7 @@ namespace Microsoft.Azure.Cosmos ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedRequestOptions requestOptions = null) { - ChangeFeedRequestOptions cosmosQueryRequestOptions = requestOptions as ChangeFeedRequestOptions ?? new ChangeFeedRequestOptions(); + ChangeFeedRequestOptions cosmosQueryRequestOptions = requestOptions ?? new ChangeFeedRequestOptions(); return new StandByFeedIteratorCore( clientContext: this.ClientContext, @@ -717,10 +717,10 @@ namespace Microsoft.Azure.Cosmos return responseMessage; } - + public override async Task GetPartitionKeyValueFromStreamAsync( Stream stream, - CancellationToken cancellation = default(CancellationToken)) + CancellationToken cancellation = default) { if (!stream.CanSeek) { @@ -747,8 +747,7 @@ namespace Microsoft.Azure.Cosmos foreach (IReadOnlyList tokenList in tokenslist) { - CosmosElement element; - if (ContainerCore.TryParseTokenListForElement(pathTraversal, tokenList, out element)) + if (ContainerCore.TryParseTokenListForElement(pathTraversal, tokenList, out CosmosElement element)) { cosmosElementList.Add(element); } @@ -786,7 +785,7 @@ namespace Microsoft.Azure.Cosmos return true; } - private static PartitionKey CosmosElementToPartitionKeyObject(IReadOnlyList cosmosElementList) + private static PartitionKey CosmosElementToPartitionKeyObject(IReadOnlyList cosmosElementList) { PartitionKeyBuilder partitionKeyBuilder = new PartitionKeyBuilder(); diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs index 0b464750a..a657beb68 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs @@ -64,7 +64,7 @@ namespace Microsoft.Azure.Cosmos public async Task ReadContainerAsync( CosmosDiagnosticsContext diagnosticsContext, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { ResponseMessage response = await this.ReadContainerStreamAsync( diagnosticsContext: diagnosticsContext, @@ -78,7 +78,7 @@ namespace Microsoft.Azure.Cosmos CosmosDiagnosticsContext diagnosticsContext, ContainerProperties containerProperties, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (containerProperties == null) { @@ -98,7 +98,7 @@ namespace Microsoft.Azure.Cosmos public async Task DeleteContainerAsync( CosmosDiagnosticsContext diagnosticsContext, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { ResponseMessage response = await this.DeleteContainerStreamAsync( diagnosticsContext: diagnosticsContext, @@ -110,7 +110,7 @@ namespace Microsoft.Azure.Cosmos public async Task ReadThroughputAsync( CosmosDiagnosticsContext diagnosticsContext, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { ThroughputResponse response = await this.ReadThroughputIfExistsAsync(null, cancellationToken); return response.Resource?.Throughput; @@ -119,7 +119,7 @@ namespace Microsoft.Azure.Cosmos public async Task ReadThroughputAsync( CosmosDiagnosticsContext diagnosticsContext, RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { string rid = await this.GetRIDAsync(cancellationToken); CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext); @@ -129,7 +129,7 @@ namespace Microsoft.Azure.Cosmos public async Task ReadThroughputIfExistsAsync( CosmosDiagnosticsContext diagnosticsContext, RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { string rid = await this.GetRIDAsync(cancellationToken); CosmosOffers cosmosOffers = new CosmosOffers(this.ClientContext); @@ -140,7 +140,7 @@ namespace Microsoft.Azure.Cosmos CosmosDiagnosticsContext diagnosticsContext, int throughput, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { string rid = await this.GetRIDAsync(cancellationToken); @@ -156,7 +156,7 @@ namespace Microsoft.Azure.Cosmos CosmosDiagnosticsContext diagnosticsContext, ThroughputProperties throughput, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { string rid = await this.GetRIDAsync(cancellationToken); @@ -186,7 +186,7 @@ namespace Microsoft.Azure.Cosmos public Task DeleteContainerStreamAsync( CosmosDiagnosticsContext diagnosticsContext, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ProcessStreamAsync( diagnosticsContext: diagnosticsContext, @@ -199,7 +199,7 @@ namespace Microsoft.Azure.Cosmos public Task ReadContainerStreamAsync( CosmosDiagnosticsContext diagnosticsContext, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ProcessStreamAsync( diagnosticsContext: diagnosticsContext, @@ -213,7 +213,7 @@ namespace Microsoft.Azure.Cosmos CosmosDiagnosticsContext diagnosticsContext, ContainerProperties containerProperties, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { if (containerProperties == null) { @@ -230,7 +230,7 @@ namespace Microsoft.Azure.Cosmos public async Task> GetFeedRangesAsync( CosmosDiagnosticsContext diagnosticsContext, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { PartitionKeyRangeCache partitionKeyRangeCache = await this.ClientContext.DocumentClient.GetPartitionKeyRangeCacheAsync(); string containerRId = await this.GetRIDAsync(cancellationToken); @@ -285,7 +285,7 @@ namespace Microsoft.Azure.Cosmos public override async Task> GetPartitionKeyRangesAsync( FeedRange feedRange, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { IRoutingMapProvider routingMapProvider = await this.ClientContext.DocumentClient.GetPartitionKeyRangeCacheAsync(); string containerRid = await this.GetRIDAsync(cancellationToken); @@ -305,7 +305,7 @@ namespace Microsoft.Azure.Cosmos /// /// representing request cancellation. /// A containing the for this container. - public override async Task GetCachedContainerPropertiesAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override async Task GetCachedContainerPropertiesAsync(CancellationToken cancellationToken = default) { ClientCollectionCache collectionCache = await this.ClientContext.DocumentClient.GetCollectionCacheAsync(); try @@ -327,7 +327,7 @@ namespace Microsoft.Azure.Cosmos return containerProperties?.ResourceId; } - public override Task GetPartitionKeyDefinitionAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override Task GetPartitionKeyDefinitionAsync(CancellationToken cancellationToken = default) { return this.GetCachedContainerPropertiesAsync(cancellationToken) .ContinueWith(containerPropertiesTask => containerPropertiesTask.Result?.PartitionKey, cancellationToken); @@ -338,7 +338,7 @@ namespace Microsoft.Azure.Cosmos /// /// /// Returns the partition key path - public override async Task>> GetPartitionKeyPathTokensAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override async Task>> GetPartitionKeyPathTokensAsync(CancellationToken cancellationToken = default) { ContainerProperties containerProperties = await this.GetCachedContainerPropertiesAsync(cancellationToken); if (containerProperties == null) @@ -364,7 +364,7 @@ namespace Microsoft.Azure.Cosmos /// /// For non-existing container will throw with 404 as status code /// - public override async Task GetNonePartitionKeyValueAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override async Task GetNonePartitionKeyValueAsync(CancellationToken cancellationToken = default) { ContainerProperties containerProperties = await this.GetCachedContainerPropertiesAsync(cancellationToken); return containerProperties.GetNoneValue(); @@ -396,7 +396,7 @@ namespace Microsoft.Azure.Cosmos CosmosDiagnosticsContext diagnosticsContext, Stream streamPayload, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ProcessStreamAsync( diagnosticsContext: diagnosticsContext, @@ -411,7 +411,7 @@ namespace Microsoft.Azure.Cosmos Stream streamPayload, OperationType operationType, ContainerRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ProcessResourceOperationStreamAsync( diagnosticsContext: diagnosticsContext, @@ -430,7 +430,7 @@ namespace Microsoft.Azure.Cosmos string linkUri, ResourceType resourceType, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ClientContext.ProcessResourceOperationStreamAsync( resourceUri: linkUri, diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs index b958ea0d8..12455efd4 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs @@ -134,7 +134,7 @@ namespace Microsoft.Azure.Cosmos return this.ClientContext.OperationHelperAsync( nameof(ReadThroughputIfExistsAsync), requestOptions, - (diagnostics) => base.ReadThroughputIfExistsAsync(diagnostics, requestOptions, cancellationToken)); + (diagnostics) => base.ReadThroughputIfExistsAsync(diagnostics, requestOptions, cancellationToken)); } public override Task ReplaceThroughputIfExistsAsync(ThroughputProperties throughput, RequestOptions requestOptions, CancellationToken cancellationToken) @@ -364,7 +364,7 @@ namespace Microsoft.Azure.Cosmos return base.CreateTransactionalBatch(partitionKey); } - public override Task> GetFeedRangesAsync(CancellationToken cancellationToken = default(CancellationToken)) + public override Task> GetFeedRangesAsync(CancellationToken cancellationToken = default) { return this.ClientContext.OperationHelperAsync( nameof(GetFeedRangesAsync), @@ -388,7 +388,7 @@ namespace Microsoft.Azure.Cosmos public override Task> GetPartitionKeyRangesAsync( FeedRange feedRange, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ClientContext.OperationHelperAsync( nameof(GetPartitionKeyRangesAsync), diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs index b21102f14..ea9f6a09b 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs @@ -37,10 +37,10 @@ namespace Microsoft.Azure.Cosmos CancellationToken cancellationToken); public abstract Task GetCachedContainerPropertiesAsync( - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); public abstract Task>> GetPartitionKeyPathTokensAsync( - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); public abstract Task GetNonePartitionKeyValueAsync( CancellationToken cancellationToken); @@ -71,7 +71,7 @@ namespace Microsoft.Azure.Cosmos CancellationToken cancellation); public abstract Task> GetChangeFeedTokensAsync( - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Throw an exception if the partition key is null or empty string @@ -97,19 +97,19 @@ namespace Microsoft.Azure.Cosmos PartitionKey partitionKey, IReadOnlyList patchOperations, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); public abstract Task> PatchItemAsync( string id, PartitionKey partitionKey, IReadOnlyList patchOperations, ItemRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); #endif #if !PREVIEW - public abstract Task> GetFeedRangesAsync(CancellationToken cancellationToken = default(CancellationToken)); + public abstract Task> GetFeedRangesAsync(CancellationToken cancellationToken = default); public abstract FeedIterator GetChangeFeedStreamIterator( ChangeFeedStartFrom changeFeedStartFrom, @@ -121,7 +121,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task> GetPartitionKeyRangesAsync( FeedRange feedRange, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); public abstract FeedIterator GetItemQueryStreamIterator( FeedRange feedRange, diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerResponse.cs index 69d8e9f39..6b5f2680c 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerResponse.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System.Net; - using Microsoft.Azure.Documents; /// /// The cosmos container response diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ItemResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ItemResponse.cs index 8c0b27828..e14d386e5 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ItemResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ItemResponse.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System.Net; - using Microsoft.Azure.Documents; /// /// The cosmos item response diff --git a/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs b/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs index c3b39c241..35466730c 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs @@ -5,13 +5,10 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Globalization; using System.IO; - using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Handlers; - using Microsoft.Azure.Cosmos.Query; using Microsoft.Azure.Documents; /// diff --git a/Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs b/Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs index 1ec777e96..695699c72 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Cosmos { using System; using System.Collections; - using System.Threading; /// /// The exception that is thrown in a thread upon cancellation of an operation that diff --git a/Microsoft.Azure.Cosmos/src/Resource/CosmosQuotaResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/CosmosQuotaResponse.cs index 37909a661..664da8d6e 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/CosmosQuotaResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/CosmosQuotaResponse.cs @@ -31,7 +31,7 @@ namespace Microsoft.Azure.Cosmos internal CosmosQuotaResponse(string quotaInfo) { this.source = quotaInfo; - ParseQuotaString(quotaInfo); + this.ParseQuotaString(quotaInfo); } /// diff --git a/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryCore.cs b/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryCore.cs index 4b83c1c00..3d2f591a6 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryCore.cs @@ -23,8 +23,7 @@ namespace Microsoft.Azure.Cosmos public override FeedResponse CreateItemFeedResponse(ResponseMessage responseMessage) { return this.CreateQueryFeedResponseHelper( - responseMessage, - Documents.ResourceType.Document); + responseMessage); } public override FeedResponse CreateChangeFeedUserTypeResponse( @@ -38,8 +37,7 @@ namespace Microsoft.Azure.Cosmos ResponseMessage responseMessage) { return this.CreateQueryFeedResponseHelper( - responseMessage, - Documents.ResourceType.Document); + responseMessage); } public override FeedResponse CreateQueryFeedResponse( @@ -47,13 +45,11 @@ namespace Microsoft.Azure.Cosmos Documents.ResourceType resourceType) { return this.CreateQueryFeedResponseHelper( - responseMessage, - resourceType); + responseMessage); } private FeedResponse CreateQueryFeedResponseHelper( - ResponseMessage cosmosResponseMessage, - Documents.ResourceType resourceType) + ResponseMessage cosmosResponseMessage) { if (cosmosResponseMessage is QueryResponse queryResponse) { @@ -236,7 +232,7 @@ namespace Microsoft.Azure.Cosmos { if (responseMessage.Content == null) { - return default(T); + return default; } return this.serializerCore.FromStream(responseMessage.Content); diff --git a/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryInternal.cs b/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryInternal.cs index 30de4f468..a8c89c3f8 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactoryInternal.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Scripts; internal abstract class CosmosResponseFactoryInternal : CosmosResponseFactory diff --git a/Microsoft.Azure.Cosmos/src/Resource/Database/Database.cs b/Microsoft.Azure.Cosmos/src/Resource/Database/Database.cs index 4749a866d..aa6a5fedf 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Database/Database.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Database/Database.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Fluent; @@ -57,7 +56,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task ReadAsync( RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a Database from the Azure Cosmos DB service as an asynchronous operation. @@ -77,7 +76,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task DeleteAsync( RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Gets database throughput in measurement of request units per second in the Azure Cosmos service. /// @@ -101,7 +100,7 @@ namespace Microsoft.Azure.Cosmos /// /// public abstract Task ReadThroughputAsync( - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Gets database throughput in measurement of request units per second in the Azure Cosmos service. @@ -142,7 +141,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task ReadThroughputAsync( RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Sets throughput provisioned for a database in measurement of request units per second in the Azure Cosmos service. @@ -180,7 +179,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReplaceThroughputAsync( ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a container as an asynchronous operation in the Azure Cosmos service. @@ -217,7 +216,7 @@ namespace Microsoft.Azure.Cosmos ContainerProperties containerProperties, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Check if a container exists, and if it doesn't, create it. @@ -267,7 +266,7 @@ namespace Microsoft.Azure.Cosmos ContainerProperties containerProperties, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a container as an asynchronous operation in the Azure Cosmos service. @@ -302,7 +301,7 @@ namespace Microsoft.Azure.Cosmos ContainerProperties containerProperties, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Sets throughput provisioned for a database in measurement of request units per second in the Azure Cosmos service. @@ -329,7 +328,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReplaceThroughputAsync( int throughput, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Reads a from the Azure Cosmos service as an asynchronous operation. @@ -351,7 +350,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task ReadStreamAsync( RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos DB service as an asynchronous operation. @@ -371,7 +370,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task DeleteStreamAsync( RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Returns a reference to a container object. @@ -426,7 +425,7 @@ namespace Microsoft.Azure.Cosmos ContainerProperties containerProperties, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a container as an asynchronous operation in the Azure Cosmos service. @@ -453,7 +452,7 @@ namespace Microsoft.Azure.Cosmos string partitionKeyPath, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Check if a container exists, and if it doesn't, create it. @@ -501,7 +500,7 @@ namespace Microsoft.Azure.Cosmos ContainerProperties containerProperties, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Check if a container exists, and if it doesn't, create it. @@ -528,7 +527,7 @@ namespace Microsoft.Azure.Cosmos string partitionKeyPath, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a container as an asynchronous operation in the Azure Cosmos service. @@ -561,7 +560,7 @@ namespace Microsoft.Azure.Cosmos ContainerProperties containerProperties, int? throughput = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Returns a reference to a user object. @@ -602,7 +601,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task CreateUserAsync( string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Upserts a user as an asynchronous operation in the Azure Cosmos service. @@ -622,7 +621,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task UpsertUserAsync(string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// This method creates a query for containers under an database using a SQL statement. It returns a FeedIterator. diff --git a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInlineCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInlineCore.cs index 63bc2733d..a161a1e37 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInlineCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInlineCore.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Fluent; @@ -15,7 +14,7 @@ namespace Microsoft.Azure.Cosmos internal DatabaseInlineCore( CosmosClientContext clientContext, string databaseId) - : base ( + : base( clientContext, databaseId) { @@ -269,7 +268,7 @@ namespace Microsoft.Azure.Cosmos ContainerProperties containerProperties, ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ClientContext.OperationHelperAsync( nameof(CreateContainerIfNotExistsAsync), diff --git a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInternal.cs b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInternal.cs index cd71ec11e..3a420ca84 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInternal.cs @@ -4,10 +4,8 @@ namespace Microsoft.Azure.Cosmos { - using System; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos.Fluent; internal abstract class DatabaseInternal : Database { @@ -17,19 +15,19 @@ namespace Microsoft.Azure.Cosmos internal abstract Task ReadThroughputIfExistsAsync( RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); internal abstract Task ReplaceThroughputIfExistsAsync( int throughput, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); internal abstract Task ReplaceThroughputPropertiesIfExistsAsync( ThroughputProperties throughputProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); - internal abstract Task GetRIDAsync(CancellationToken cancellationToken = default(CancellationToken)); + internal abstract Task GetRIDAsync(CancellationToken cancellationToken = default); public abstract FeedIterator GetUserQueryStreamIterator( QueryDefinition queryDefinition, diff --git a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseResponse.cs index e40dc7f5a..12537d38f 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseResponse.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System.Net; - using Microsoft.Azure.Documents; /// /// The cosmos database response diff --git a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorCore.cs b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorCore.cs index 4e7be634a..772cde267 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorCore.cs @@ -110,7 +110,7 @@ namespace Microsoft.Azure.Cosmos { await CosmosElementSerializer.RewriteStreamAsTextAsync(responseMessage, this.requestOptions); } - + return responseMessage; } diff --git a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal.cs b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal.cs index b496a161c..9e073cec4 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; /// /// Internal feed iterator API for casting and mocking purposes. diff --git a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal{T}.cs b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal{T}.cs index d26df5d5f..32bf1d4c9 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal{T}.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInternal{T}.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using Microsoft.Azure.Cosmos.CosmosElements; - using Microsoft.Azure.Cosmos.Json; /// /// Internal API for FeedIterator for inheritance and mocking purposes. diff --git a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedRangeIteratorCore.cs b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedRangeIteratorCore.cs index 56a9ceee2..9fe6de235 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedRangeIteratorCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedRangeIteratorCore.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos using System; using System.Collections.Generic; using System.IO; - using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.CosmosElements; diff --git a/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs b/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs index 7b81f6be6..a20d567b0 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs @@ -27,7 +27,7 @@ namespace Microsoft.Azure.Cosmos internal async Task ReadThroughputAsync( string targetRID, RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { OfferV2 offerV2 = await this.GetOfferV2Async(targetRID, failIfNotConfigured: true, cancellationToken: cancellationToken); @@ -43,7 +43,7 @@ namespace Microsoft.Azure.Cosmos internal async Task ReadThroughputIfExistsAsync( string targetRID, RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { OfferV2 offerV2 = await this.GetOfferV2Async(targetRID, failIfNotConfigured: false, cancellationToken: cancellationToken); @@ -87,7 +87,7 @@ namespace Microsoft.Azure.Cosmos string targetRID, ThroughputProperties throughputProperties, RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { try { @@ -138,7 +138,7 @@ namespace Microsoft.Azure.Cosmos string targetRID, int throughput, RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ReplaceThroughputPropertiesAsync( targetRID, @@ -151,7 +151,7 @@ namespace Microsoft.Azure.Cosmos string targetRID, int throughput, RequestOptions requestOptions, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return this.ReplaceThroughputPropertiesIfExistsAsync( targetRID, @@ -184,7 +184,7 @@ namespace Microsoft.Azure.Cosmos if (offerV2 == null && failIfNotConfigured) { - throw (CosmosException)CosmosExceptionFactory.CreateNotFoundException( + throw CosmosExceptionFactory.CreateNotFoundException( $"Throughput is not configured for {targetRID}"); } @@ -217,7 +217,7 @@ namespace Microsoft.Azure.Cosmos QueryDefinition queryDefinition, string continuationToken = null, QueryRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { return new FeedIteratorCore( clientContext: this.ClientContext, @@ -230,7 +230,7 @@ namespace Microsoft.Azure.Cosmos private async Task SingleOrDefaultAsync( FeedIterator offerQuery, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { while (offerQuery.HasMoreResults) { @@ -241,7 +241,7 @@ namespace Microsoft.Azure.Cosmos } } - return default(T); + return default; } private async Task GetThroughputResponseAsync( @@ -250,7 +250,7 @@ namespace Microsoft.Azure.Cosmos Uri linkUri, ResourceType resourceType, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)) + CancellationToken cancellationToken = default) { ResponseMessage responseMessage = await this.ClientContext.ProcessResourceOperationStreamAsync( resourceUri: linkUri.OriginalString, diff --git a/Microsoft.Azure.Cosmos/src/Resource/Offer/OfferAutoscaleProperties.cs b/Microsoft.Azure.Cosmos/src/Resource/Offer/OfferAutoscaleProperties.cs index de29a083e..d5c243997 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Offer/OfferAutoscaleProperties.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Offer/OfferAutoscaleProperties.cs @@ -22,14 +22,9 @@ namespace Microsoft.Azure.Cosmos int? autoUpgradeMaxThroughputIncrementPercentage) { this.MaxThroughput = startingMaxThroughput; - if (autoUpgradeMaxThroughputIncrementPercentage.HasValue) - { - this.AutoscaleAutoUpgradeProperties = new OfferAutoscaleAutoUpgradeProperties(autoUpgradeMaxThroughputIncrementPercentage.Value); - } - else - { - this.AutoscaleAutoUpgradeProperties = null; - } + this.AutoscaleAutoUpgradeProperties = autoUpgradeMaxThroughputIncrementPercentage.HasValue + ? new OfferAutoscaleAutoUpgradeProperties(autoUpgradeMaxThroughputIncrementPercentage.Value) + : null; } /// diff --git a/Microsoft.Azure.Cosmos/src/Resource/Permission/Permission.cs b/Microsoft.Azure.Cosmos/src/Resource/Permission/Permission.cs index 39ac07477..3acf25538 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Permission/Permission.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Permission/Permission.cs @@ -62,7 +62,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReadAsync( int? tokenExpiryInSeconds = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replace a from the Azure Cosmos service as an asynchronous operation. This will not revoke existing ResourceTokens. @@ -89,7 +89,7 @@ namespace Microsoft.Azure.Cosmos PermissionProperties permissionProperties, int? tokenExpiryInSeconds = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos DB service as an asynchronous operation. This will not revoke existing ResourceTokens. @@ -109,6 +109,6 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task DeleteAsync( RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); } } diff --git a/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionResponse.cs index d0a795fd8..3edf03f68 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionResponse.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System.Net; - using Microsoft.Azure.Documents; /// /// The cosmos permission response diff --git a/Microsoft.Azure.Cosmos/src/Resource/Scripts/Scripts.cs b/Microsoft.Azure.Cosmos/src/Resource/Scripts/Scripts.cs index d60fcc786..20b6cf1fa 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Scripts/Scripts.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Scripts/Scripts.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Scripts { - using System; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -65,7 +64,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task CreateStoredProcedureAsync( StoredProcedureProperties storedProcedureProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// This method creates a query for stored procedures under a container using a SQL statement. It returns a FeedIterator. @@ -246,7 +245,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task ReadStoredProcedureAsync( string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replaces a in the Azure Cosmos service as an asynchronous operation. @@ -281,7 +280,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task ReplaceStoredProcedureAsync( StoredProcedureProperties storedProcedureProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos DB service as an asynchronous operation. @@ -303,7 +302,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task DeleteStoredProcedureAsync( string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Executes a stored procedure against a container as an asynchronous operation in the Azure Cosmos service. @@ -361,7 +360,7 @@ namespace Microsoft.Azure.Cosmos.Scripts PartitionKey partitionKey, dynamic[] parameters, StoredProcedureRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Executes a stored procedure against a container as an asynchronous operation in the Azure Cosmos service and obtains a Stream as response. @@ -423,7 +422,7 @@ namespace Microsoft.Azure.Cosmos.Scripts PartitionKey partitionKey, dynamic[] parameters, StoredProcedureRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Executes a stored procedure against a container as an asynchronous operation in the Azure Cosmos service and obtains a Stream as response. @@ -490,7 +489,7 @@ namespace Microsoft.Azure.Cosmos.Scripts Stream streamPayload, PartitionKey partitionKey, StoredProcedureRequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a trigger as an asynchronous operation in the Azure Cosmos DB service. @@ -536,7 +535,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task CreateTriggerAsync( TriggerProperties triggerProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// This method creates a query for triggers under a container using a SQL statement. It returns a FeedIterator. @@ -695,7 +694,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task ReadTriggerAsync( string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replaces a in the Azure Cosmos service as an asynchronous operation. @@ -735,7 +734,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task ReplaceTriggerAsync( TriggerProperties triggerProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos service as an asynchronous operation. @@ -757,7 +756,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task DeleteTriggerAsync( string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Creates a user defined function as an asynchronous operation in the Azure Cosmos DB service. @@ -802,7 +801,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task CreateUserDefinedFunctionAsync( UserDefinedFunctionProperties userDefinedFunctionProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// This method creates a query for user defined functions under a container using a SQL statement. It returns a FeedIterator. @@ -975,7 +974,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task ReadUserDefinedFunctionAsync( string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replaces a in the Azure Cosmos DB service as an asynchronous operation. @@ -1005,7 +1004,7 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task ReplaceUserDefinedFunctionAsync( UserDefinedFunctionProperties userDefinedFunctionProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos DB service as an asynchronous operation. @@ -1027,6 +1026,6 @@ namespace Microsoft.Azure.Cosmos.Scripts public abstract Task DeleteUserDefinedFunctionAsync( string id, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); } } diff --git a/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs index a73ee09b0..899d1167e 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs @@ -220,7 +220,7 @@ namespace Microsoft.Azure.Cosmos.Scripts } ContainerInternal.ValidatePartitionKey(partitionKey, requestOptions); - + string linkUri = this.ClientContext.CreateLink( parentLink: this.container.LinkUri, uriPathSegment: Paths.StoredProceduresPathSegment, diff --git a/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsInlineCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsInlineCore.cs index 49b0050e6..f4dc266a2 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsInlineCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsInlineCore.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Scripts { - using System; using System.IO; using System.Threading; using System.Threading.Tasks; diff --git a/Microsoft.Azure.Cosmos/src/Resource/Scripts/TriggerResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Scripts/TriggerResponse.cs index 8d8c28251..dab6dad0c 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Scripts/TriggerResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Scripts/TriggerResponse.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos.Scripts { using System.Net; - using Microsoft.Azure.Documents; /// /// The cosmos trigger response diff --git a/Microsoft.Azure.Cosmos/src/Resource/Scripts/UserDefinedFunctionResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Scripts/UserDefinedFunctionResponse.cs index 1a3bd4927..95f51e3ac 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Scripts/UserDefinedFunctionResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Scripts/UserDefinedFunctionResponse.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos.Scripts { using System.Net; - using Microsoft.Azure.Documents; /// /// The cosmos user defined function response diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/AccountProperties.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/AccountProperties.cs index 53c98c118..99afcae6b 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/AccountProperties.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/AccountProperties.cs @@ -25,7 +25,7 @@ namespace Microsoft.Azure.Cosmos /// internal AccountProperties() { - this.QueryEngineConfigurationInternal = new Lazy>(() => QueryStringToDictConverter()); + this.QueryEngineConfigurationInternal = new Lazy>(() => this.QueryStringToDictConverter()); } /// diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/BoundingBoxProperties.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/BoundingBoxProperties.cs index 83b82db6a..003914e24 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/BoundingBoxProperties.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/BoundingBoxProperties.cs @@ -3,12 +3,7 @@ //------------------------------------------------------------ namespace Microsoft.Azure.Cosmos { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using Microsoft.Azure.Documents; using Newtonsoft.Json; - using Newtonsoft.Json.Converters; /// /// Represents bounding box for geometry spatial path in the Azure Cosmos DB service diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/ContainerProperties.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/ContainerProperties.cs index 4a54875ef..62cc3dcc6 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/ContainerProperties.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/ContainerProperties.cs @@ -290,10 +290,7 @@ namespace Microsoft.Azure.Cosmos return this.geospatialConfigInternal; } - set - { - this.geospatialConfigInternal = value; - } + set => this.geospatialConfigInternal = value; } /// /// JSON path used for containers partitioning @@ -301,17 +298,15 @@ namespace Microsoft.Azure.Cosmos [JsonIgnore] public string PartitionKeyPath { - get - { - #if SUBPARTITIONING + get => +#if SUBPARTITIONING if (this.PartitionKey?.Kind == PartitionKind.MultiHash && this.PartitionKey?.Paths.Count > 1) { throw new NotImplementedException($"This MultiHash collection has more than 1 partition key path please use `PartitionKeyPaths`"); } - #endif - return this.PartitionKey?.Paths != null && this.PartitionKey.Paths.Count > 0 ? this.PartitionKey?.Paths[0] : null; - } +#endif + this.PartitionKey?.Paths != null && this.PartitionKey.Paths.Count > 0 ? this.PartitionKey?.Paths[0] : null; set { if (string.IsNullOrEmpty(value)) @@ -587,7 +582,7 @@ namespace Microsoft.Azure.Cosmos throw new ArgumentNullException(nameof(this.PartitionKey)); } - if (this.PartitionKey.Paths.Count > 1 && this.PartitionKey.Kind != Documents.PartitionKind.MultiHash) + if (this.PartitionKey.Paths.Count > 1 && this.PartitionKey.Kind != Documents.PartitionKind.MultiHash) { throw new NotImplementedException("PartitionKey extraction with composite partition keys not supported."); } diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/CosmosResource.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/CosmosResource.cs index f79f917e1..3e984c758 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/CosmosResource.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/CosmosResource.cs @@ -14,7 +14,7 @@ namespace Microsoft.Azure.Cosmos /// internal static class CosmosResource { - private static CosmosJsonDotNetSerializer cosmosDefaultJsonSerializer = new CosmosJsonDotNetSerializer(); + private static readonly CosmosJsonDotNetSerializer cosmosDefaultJsonSerializer = new CosmosJsonDotNetSerializer(); internal static T FromStream(DocumentServiceResponse response) { @@ -28,7 +28,7 @@ namespace Microsoft.Azure.Cosmos return CosmosResource.FromStream(response.ResponseBody); } - return default(T); + return default; } internal static Stream ToStream(T input) diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/GeospatialConfig.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/GeospatialConfig.cs index 61b8e930a..74c9f9ec9 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/GeospatialConfig.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/GeospatialConfig.cs @@ -3,10 +3,6 @@ //------------------------------------------------------------ namespace Microsoft.Azure.Cosmos { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using Microsoft.Azure.Documents; using Newtonsoft.Json; using Newtonsoft.Json.Converters; diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/UserProperties.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/UserProperties.cs index 5c7541f32..120ea09da 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/UserProperties.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/UserProperties.cs @@ -112,12 +112,6 @@ namespace Microsoft.Azure.Cosmos /// Gets the self-link of the permissions associated with the user for the Azure Cosmos DB service. /// /// The self-link of the permissions associated with the user. - internal string PermissionsLink - { - get - { - return $"{this.SelfLink?.TrimEnd('/')}/{ this.Permissions}"; - } - } + internal string PermissionsLink => $"{this.SelfLink?.TrimEnd('/')}/{ this.Permissions}"; } } diff --git a/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs index 5cca91dd9..5283974fa 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System; using System.Net; using Microsoft.Azure.Documents; @@ -82,7 +81,7 @@ namespace Microsoft.Azure.Cosmos { if (this.Headers.GetHeaderValue(WFConstants.BackendHeaders.OfferReplacePending) != null) { - return Boolean.Parse(this.Headers.GetHeaderValue(WFConstants.BackendHeaders.OfferReplacePending)); + return bool.Parse(this.Headers.GetHeaderValue(WFConstants.BackendHeaders.OfferReplacePending)); } return null; } diff --git a/Microsoft.Azure.Cosmos/src/Resource/User/User.cs b/Microsoft.Azure.Cosmos/src/Resource/User/User.cs index 3628bb548..1c8e2f8fc 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/User/User.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/User/User.cs @@ -36,7 +36,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task ReadAsync( RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Replace a from the Azure Cosmos service as an asynchronous operation. @@ -61,7 +61,7 @@ namespace Microsoft.Azure.Cosmos public abstract Task ReplaceAsync( UserProperties userProperties, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Delete a from the Azure Cosmos DB service as an asynchronous operation. @@ -80,7 +80,7 @@ namespace Microsoft.Azure.Cosmos /// public abstract Task DeleteAsync( RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Returns a reference to a permission object. @@ -124,7 +124,7 @@ namespace Microsoft.Azure.Cosmos PermissionProperties permissionProperties, int? tokenExpiryInSeconds = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// Upsert a permission as an asynchronous operation in the Azure Cosmos service. @@ -149,7 +149,7 @@ namespace Microsoft.Azure.Cosmos PermissionProperties permissionProperties, int? tokenExpiryInSeconds = null, RequestOptions requestOptions = null, - CancellationToken cancellationToken = default(CancellationToken)); + CancellationToken cancellationToken = default); /// /// This method creates a query for permission under a user using a SQL statement. It returns a FeedIterator. diff --git a/Microsoft.Azure.Cosmos/src/Resource/User/UserInlineCore.cs b/Microsoft.Azure.Cosmos/src/Resource/User/UserInlineCore.cs index 53b1ead21..f55351422 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/User/UserInlineCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/User/UserInlineCore.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using System; using System.Threading; using System.Threading.Tasks; diff --git a/Microsoft.Azure.Cosmos/src/Resource/User/UserResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/User/UserResponse.cs index 999364197..09b019912 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/User/UserResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/User/UserResponse.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System.Net; - using Microsoft.Azure.Documents; /// /// The cosmos user response diff --git a/Microsoft.Azure.Cosmos/src/ResourceFeedReader.cs b/Microsoft.Azure.Cosmos/src/ResourceFeedReader.cs index fdb677d2f..bb864f746 100644 --- a/Microsoft.Azure.Cosmos/src/ResourceFeedReader.cs +++ b/Microsoft.Azure.Cosmos/src/ResourceFeedReader.cs @@ -74,10 +74,7 @@ namespace Microsoft.Azure.Cosmos /// Gets a value indicating whether there are additional results to retrieve from the Azure Cosmos DB service. /// /// Returns true if there are additional results to retrieve. Returns false otherwise. - public bool HasMoreResults - { - get { return this.documentQuery.HasMoreResults; } - } + public bool HasMoreResults => this.documentQuery.HasMoreResults; /// /// Retrieves an that can be used to iterate over the resources from the Azure Cosmos DB service. @@ -105,7 +102,7 @@ namespace Microsoft.Azure.Cosmos /// /// (Optional) The allows for notification that operations should be cancelled. /// The response from a single call to ReadFeed for the specified resource. - public Task> ExecuteNextAsync(CancellationToken cancellationToken = default(CancellationToken)) + public Task> ExecuteNextAsync(CancellationToken cancellationToken = default) { return TaskHelper.InlineIfPossible(() => this.InternalExecuteNextAsync(cancellationToken), null, cancellationToken); } diff --git a/Microsoft.Azure.Cosmos/src/Serializer/CosmosJsonDotNetSerializer.cs b/Microsoft.Azure.Cosmos/src/Serializer/CosmosJsonDotNetSerializer.cs index 1ff788f40..8d21325ef 100644 --- a/Microsoft.Azure.Cosmos/src/Serializer/CosmosJsonDotNetSerializer.cs +++ b/Microsoft.Azure.Cosmos/src/Serializer/CosmosJsonDotNetSerializer.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Diagnostics; using System.IO; using System.Text; using Newtonsoft.Json; diff --git a/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationOptions.cs b/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationOptions.cs index 16995772f..965d82401 100644 --- a/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationOptions.cs +++ b/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationOptions.cs @@ -4,8 +4,6 @@ namespace Microsoft.Azure.Cosmos { - using Newtonsoft.Json.Serialization; - /// /// This class provides a way to configure basic /// serializer settings. diff --git a/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationUtil.cs b/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationUtil.cs index 07657887f..4a53fe43c 100644 --- a/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationUtil.cs +++ b/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializationUtil.cs @@ -8,7 +8,7 @@ namespace Microsoft.Azure.Cosmos internal static class CosmosSerializationUtil { - private static CamelCaseNamingStrategy camelCaseNamingStrategy = new CamelCaseNamingStrategy(); + private static readonly CamelCaseNamingStrategy camelCaseNamingStrategy = new CamelCaseNamingStrategy(); internal static string ToCamelCase(string name) { diff --git a/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializerCore.cs b/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializerCore.cs index dca219b07..f957d67c2 100644 --- a/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializerCore.cs +++ b/Microsoft.Azure.Cosmos/src/Serializer/CosmosSerializerCore.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Collections.Generic; using System.IO; using Microsoft.Azure.Cosmos.Query.Core; using Microsoft.Azure.Cosmos.Query.Core.QueryPlan; diff --git a/Microsoft.Azure.Cosmos/src/Serializer/FeedRange/FeedRangeInternalConverter.cs b/Microsoft.Azure.Cosmos/src/Serializer/FeedRange/FeedRangeInternalConverter.cs index 2f7704706..00ab5ce8d 100644 --- a/Microsoft.Azure.Cosmos/src/Serializer/FeedRange/FeedRangeInternalConverter.cs +++ b/Microsoft.Azure.Cosmos/src/Serializer/FeedRange/FeedRangeInternalConverter.cs @@ -14,7 +14,7 @@ namespace Microsoft.Azure.Cosmos private const string RangePropertyName = "Range"; private const string PartitionKeyPropertyName = "PK"; private const string PartitionKeyRangeIdPropertyName = "PKRangeId"; - private static RangeJsonConverter rangeJsonConverter = new RangeJsonConverter(); + private static readonly RangeJsonConverter rangeJsonConverter = new RangeJsonConverter(); public override bool CanConvert(Type objectType) { diff --git a/Microsoft.Azure.Cosmos/src/Spatial/Converters/GeometryJsonConverter.cs b/Microsoft.Azure.Cosmos/src/Spatial/Converters/GeometryJsonConverter.cs index f43d3db47..85b58be06 100644 --- a/Microsoft.Azure.Cosmos/src/Spatial/Converters/GeometryJsonConverter.cs +++ b/Microsoft.Azure.Cosmos/src/Spatial/Converters/GeometryJsonConverter.cs @@ -18,13 +18,7 @@ namespace Microsoft.Azure.Cosmos.Spatial.Converters /// Gets a value indicating whether this can write JSON. /// /// true if this can write JSON; otherwise, false. - public override bool CanWrite - { - get - { - return false; - } - } + public override bool CanWrite => false; /// /// Writes the JSON representation of the object. diff --git a/Microsoft.Azure.Cosmos/src/Spatial/Crs.cs b/Microsoft.Azure.Cosmos/src/Spatial/Crs.cs index baf4dba38..94427b701 100644 --- a/Microsoft.Azure.Cosmos/src/Spatial/Crs.cs +++ b/Microsoft.Azure.Cosmos/src/Spatial/Crs.cs @@ -29,24 +29,12 @@ namespace Microsoft.Azure.Cosmos.Spatial /// /// Gets default CRS in the Azure Cosmos DB service. Default CRS is named CRS with the name "urn:ogc:def:crs:OGC:1.3:CRS84". /// - public static Crs Default - { - get - { - return new NamedCrs("urn:ogc:def:crs:OGC:1.3:CRS84"); - } - } + public static Crs Default => new NamedCrs("urn:ogc:def:crs:OGC:1.3:CRS84"); /// /// Gets "Unspecified" CRS in the Azure Cosmos DB service. No CRS can be assumed for Geometries having "Unspecified" CRS. /// - public static Crs Unspecified - { - get - { - return new UnspecifiedCrs(); - } - } + public static Crs Unspecified => new UnspecifiedCrs(); /// /// Gets CRS type in the Azure Cosmos DB service. diff --git a/Microsoft.Azure.Cosmos/src/Spatial/Geometry.cs b/Microsoft.Azure.Cosmos/src/Spatial/Geometry.cs index 81f9bba1a..e3ab8e276 100644 --- a/Microsoft.Azure.Cosmos/src/Spatial/Geometry.cs +++ b/Microsoft.Azure.Cosmos/src/Spatial/Geometry.cs @@ -58,13 +58,7 @@ namespace Microsoft.Azure.Cosmos.Spatial /// /// The Coordinate Reference System for this geometry. /// - public Crs Crs - { - get - { - return this.CrsForSerialization ?? Crs.Default; - } - } + public Crs Crs => this.CrsForSerialization ?? Crs.Default; /// /// Gets geometry type in the Azure Cosmos DB service. diff --git a/Microsoft.Azure.Cosmos/src/Spatial/Position.cs b/Microsoft.Azure.Cosmos/src/Spatial/Position.cs index b4dc317fa..de44b8895 100644 --- a/Microsoft.Azure.Cosmos/src/Spatial/Position.cs +++ b/Microsoft.Azure.Cosmos/src/Spatial/Position.cs @@ -94,10 +94,7 @@ namespace Microsoft.Azure.Cosmos.Spatial /// /// Longitude value. /// - public double Longitude - { - get { return this.Coordinates[0]; } - } + public double Longitude => this.Coordinates[0]; /// /// Gets latitude in the Azure Cosmos DB service. @@ -105,10 +102,7 @@ namespace Microsoft.Azure.Cosmos.Spatial /// /// Latitude value. /// - public double Latitude - { - get { return this.Coordinates[1]; } - } + public double Latitude => this.Coordinates[1]; /// /// Gets optional altitude in the Azure Cosmos DB service. @@ -116,10 +110,7 @@ namespace Microsoft.Azure.Cosmos.Spatial /// /// Altitude value. /// - public double? Altitude - { - get { return this.Coordinates.Count > 2 ? (double?)this.Coordinates[2] : null; } - } + public double? Altitude => this.Coordinates.Count > 2 ? (double?)this.Coordinates[2] : null; /// /// Determines whether the specified is equal to the current in the Azure Cosmos DB service. diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlAliasedCollectionExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlAliasedCollectionExpression.cs index aa7f06a42..4c9b0e65c 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlAliasedCollectionExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlAliasedCollectionExpression.cs @@ -35,18 +35,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlAliasedCollectionExpression Create( SqlCollection collection, - SqlIdentifier alias) => new SqlAliasedCollectionExpression(collection, alias); + SqlIdentifier alias) + { + return new SqlAliasedCollectionExpression(collection, alias); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlCollectionExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlCollectionExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlCollectionExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlCollectionExpressionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlCollectionExpressionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlCollectionExpressionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayCreateScalarExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayCreateScalarExpression.cs index a3509dfad..a9fce38d1 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayCreateScalarExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayCreateScalarExpression.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.SqlObjects { using System; - using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.Azure.Cosmos.SqlObjects.Visitors; @@ -34,22 +33,49 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public ImmutableArray Items { get; } - public static SqlArrayCreateScalarExpression Create() => SqlArrayCreateScalarExpression.Empty; + public static SqlArrayCreateScalarExpression Create() + { + return SqlArrayCreateScalarExpression.Empty; + } - public static SqlArrayCreateScalarExpression Create(params SqlScalarExpression[] items) => new SqlArrayCreateScalarExpression(items.ToImmutableArray()); + public static SqlArrayCreateScalarExpression Create(params SqlScalarExpression[] items) + { + return new SqlArrayCreateScalarExpression(items.ToImmutableArray()); + } - public static SqlArrayCreateScalarExpression Create(ImmutableArray items) => new SqlArrayCreateScalarExpression(items); + public static SqlArrayCreateScalarExpression Create(ImmutableArray items) + { + return new SqlArrayCreateScalarExpression(items); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlScalarExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlScalarExpressionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayIteratorCollectionExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayIteratorCollectionExpression.cs index c538ddd71..0280bed98 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayIteratorCollectionExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlArrayIteratorCollectionExpression.cs @@ -30,18 +30,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlArrayIteratorCollectionExpression Create( SqlIdentifier identifier, - SqlCollection collection) => new SqlArrayIteratorCollectionExpression(identifier, collection); + SqlCollection collection) + { + return new SqlArrayIteratorCollectionExpression(identifier, collection); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlCollectionExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlCollectionExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlCollectionExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlCollectionExpressionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlCollectionExpressionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlCollectionExpressionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetLimitClause.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetLimitClause.cs index e7b739728..e6813c82d 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetLimitClause.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetLimitClause.cs @@ -27,12 +27,24 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlOffsetLimitClause Create( SqlOffsetSpec offsetSpec, - SqlLimitSpec limitSpec) => new SqlOffsetLimitClause(offsetSpec, limitSpec); + SqlLimitSpec limitSpec) + { + return new SqlOffsetLimitClause(offsetSpec, limitSpec); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetSpec.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetSpec.cs index dfaf60966..d797c0e21 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetSpec.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOffsetSpec.cs @@ -68,10 +68,19 @@ namespace Microsoft.Azure.Cosmos.SqlObjects return new SqlOffsetSpec(sqlParameterRefScalarExpression); } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderByItem.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderByItem.cs index df4cda50c..e0a973ebd 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderByItem.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderByItem.cs @@ -29,12 +29,24 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlOrderByItem Create( SqlScalarExpression expression, - bool isDescending) => new SqlOrderByItem(expression, isDescending); + bool isDescending) + { + return new SqlOrderByItem(expression, isDescending); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderbyClause.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderbyClause.cs index 7413eb070..4890026f8 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderbyClause.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlOrderbyClause.cs @@ -31,14 +31,29 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public ImmutableArray OrderbyItems { get; } - public static SqlOrderbyClause Create(params SqlOrderByItem[] orderbyItems) => new SqlOrderbyClause(orderbyItems.ToImmutableArray()); + public static SqlOrderbyClause Create(params SqlOrderByItem[] orderbyItems) + { + return new SqlOrderbyClause(orderbyItems.ToImmutableArray()); + } - public static SqlOrderbyClause Create(ImmutableArray orderbyItems) => new SqlOrderbyClause(orderbyItems); + public static SqlOrderbyClause Create(ImmutableArray orderbyItems) + { + return new SqlOrderbyClause(orderbyItems); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameter.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameter.cs index be6941860..2d9f17043 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameter.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameter.cs @@ -22,12 +22,24 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public string Name { get; } - public static SqlParameter Create(string name) => new SqlParameter(name); + public static SqlParameter Create(string name) + { + return new SqlParameter(name); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameterRefScalarExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameterRefScalarExpression.cs index ea8e0a059..1aa526948 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameterRefScalarExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlParameterRefScalarExpression.cs @@ -22,18 +22,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public SqlParameter Parameter { get; } - public static SqlParameterRefScalarExpression Create(SqlParameter sqlParameter) => new SqlParameterRefScalarExpression(sqlParameter); + public static SqlParameterRefScalarExpression Create(SqlParameter sqlParameter) + { + return new SqlParameterRefScalarExpression(sqlParameter); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlScalarExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlScalarExpressionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlProgram.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlProgram.cs index 4545da706..554462edf 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlProgram.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlProgram.cs @@ -22,12 +22,24 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public SqlQuery Query { get; } - public static SqlProgram Create(SqlQuery query) => new SqlProgram(query); + public static SqlProgram Create(SqlQuery query) + { + return new SqlProgram(query); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyName.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyName.cs index 2a778269f..059e799d9 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyName.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyName.cs @@ -88,10 +88,19 @@ namespace Microsoft.Azure.Cosmos.SqlObjects return sqlPropertyName; } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyRefScalarExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyRefScalarExpression.cs index 829824cae..9ca209f8f 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyRefScalarExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlPropertyRefScalarExpression.cs @@ -29,18 +29,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlPropertyRefScalarExpression Create( SqlScalarExpression member, - SqlIdentifier identifier) => new SqlPropertyRefScalarExpression(member, identifier); + SqlIdentifier identifier) + { + return new SqlPropertyRefScalarExpression(member, identifier); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlScalarExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlScalarExpressionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlQuery.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlQuery.cs index 2cb28f459..0d68c23ec 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlQuery.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlQuery.cs @@ -43,11 +43,20 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public SqlOffsetLimitClause OffsetLimitClause { get; } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } public static SqlQuery Create( SqlSelectClause selectClause, @@ -55,12 +64,15 @@ namespace Microsoft.Azure.Cosmos.SqlObjects SqlWhereClause whereClause, SqlGroupByClause groupByClause, SqlOrderbyClause orderByClause, - SqlOffsetLimitClause offsetLimitClause) => new SqlQuery( - selectClause, - fromClause, - whereClause, - groupByClause, - orderByClause, - offsetLimitClause); + SqlOffsetLimitClause offsetLimitClause) + { + return new SqlQuery( +selectClause, +fromClause, +whereClause, +groupByClause, +orderByClause, +offsetLimitClause); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectClause.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectClause.cs index f1e1aa0d5..625ee61fd 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectClause.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectClause.cs @@ -36,12 +36,24 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlSelectClause Create( SqlSelectSpec selectSpec, SqlTopSpec topSpec = null, - bool hasDistinct = false) => new SqlSelectClause(selectSpec, topSpec, hasDistinct); + bool hasDistinct = false) + { + return new SqlSelectClause(selectSpec, topSpec, hasDistinct); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectItem.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectItem.cs index d8107e186..e11f57631 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectItem.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectItem.cs @@ -29,12 +29,24 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlSelectItem Create( SqlScalarExpression expression, - SqlIdentifier alias = null) => new SqlSelectItem(expression, alias); + SqlIdentifier alias = null) + { + return new SqlSelectItem(expression, alias); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectListSpec.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectListSpec.cs index 6084b990b..8ae362f5e 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectListSpec.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectListSpec.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.SqlObjects { using System; - using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.Azure.Cosmos.SqlObjects.Visitors; @@ -32,20 +31,44 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public ImmutableArray Items { get; } - public static SqlSelectListSpec Create(params SqlSelectItem[] items) => new SqlSelectListSpec(items.ToImmutableArray()); + public static SqlSelectListSpec Create(params SqlSelectItem[] items) + { + return new SqlSelectListSpec(items.ToImmutableArray()); + } - public static SqlSelectListSpec Create(ImmutableArray items) => new SqlSelectListSpec(items); + public static SqlSelectListSpec Create(ImmutableArray items) + { + return new SqlSelectListSpec(items); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlSelectSpecVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlSelectSpecVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlSelectSpecVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlSelectSpecVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlSelectSpecVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlSelectSpecVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectStarSpec.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectStarSpec.cs index 3444752f8..38bb5dc0a 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectStarSpec.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectStarSpec.cs @@ -20,18 +20,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects { } - public static SqlSelectStarSpec Create() => SqlSelectStarSpec.Singleton; + public static SqlSelectStarSpec Create() + { + return SqlSelectStarSpec.Singleton; + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlSelectSpecVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlSelectSpecVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlSelectSpecVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlSelectSpecVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlSelectSpecVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlSelectSpecVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectValueSpec.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectValueSpec.cs index 88f07b3fe..3886f403c 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectValueSpec.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSelectValueSpec.cs @@ -23,18 +23,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public SqlScalarExpression Expression { get; } - public static SqlSelectValueSpec Create(SqlScalarExpression expression) => new SqlSelectValueSpec(expression); + public static SqlSelectValueSpec Create(SqlScalarExpression expression) + { + return new SqlSelectValueSpec(expression); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlSelectSpecVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlSelectSpecVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlSelectSpecVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlSelectSpecVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlSelectSpecVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlSelectSpecVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringLiteral.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringLiteral.cs index cf1b02d6a..ac69facba 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringLiteral.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringLiteral.cs @@ -156,14 +156,29 @@ namespace Microsoft.Azure.Cosmos.SqlObjects return sqlStringLiteral; } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlLiteralVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlLiteralVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlLiteralVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlLiteralVisitor visitor) + { + return visitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringPathExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringPathExpression.cs index 73f2ea98e..6d7d0ff70 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringPathExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlStringPathExpression.cs @@ -25,16 +25,34 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlStringPathExpression Create( SqlPathExpression parentPath, - SqlStringLiteral value) => new SqlStringPathExpression(parentPath, value); + SqlStringLiteral value) + { + return new SqlStringPathExpression(parentPath, value); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlPathExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlPathExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlPathExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlPathExpressionVisitor visitor) + { + return visitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryCollection.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryCollection.cs index b18a966cd..e8b3394e4 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryCollection.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryCollection.cs @@ -22,18 +22,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public SqlQuery Query { get; } - public static SqlSubqueryCollection Create(SqlQuery query) => new SqlSubqueryCollection(query); + public static SqlSubqueryCollection Create(SqlQuery query) + { + return new SqlSubqueryCollection(query); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlCollectionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlCollectionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlCollectionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlCollectionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlCollectionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlCollectionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryScalarExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryScalarExpression.cs index 992d9388c..0d7019695 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryScalarExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlSubqueryScalarExpression.cs @@ -22,18 +22,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public SqlQuery Query { get; } - public static SqlSubqueryScalarExpression Create(SqlQuery query) => new SqlSubqueryScalarExpression(query); + public static SqlSubqueryScalarExpression Create(SqlQuery query) + { + return new SqlSubqueryScalarExpression(query); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlScalarExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlScalarExpressionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlTopSpec.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlTopSpec.cs index 7e916278b..4a6a16c6f 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlTopSpec.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlTopSpec.cs @@ -68,10 +68,19 @@ namespace Microsoft.Azure.Cosmos.SqlObjects return new SqlTopSpec(sqlParameterRefScalarExpression); } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUnaryScalarExpression.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUnaryScalarExpression.cs index 5cea730ae..5d2e6a5c5 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUnaryScalarExpression.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUnaryScalarExpression.cs @@ -29,18 +29,39 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public static SqlUnaryScalarExpression Create( SqlUnaryScalarOperatorKind operatorKind, - SqlScalarExpression expression) => new SqlUnaryScalarExpression(operatorKind, expression); + SqlScalarExpression expression) + { + return new SqlUnaryScalarExpression(operatorKind, expression); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlScalarExpressionVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlScalarExpressionVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlScalarExpressionVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUndefinedLiteral.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUndefinedLiteral.cs index 568cea96c..e583ce142 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUndefinedLiteral.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlUndefinedLiteral.cs @@ -20,16 +20,34 @@ namespace Microsoft.Azure.Cosmos.SqlObjects { } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } - public override void Accept(SqlLiteralVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlLiteralVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlLiteralVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlLiteralVisitor visitor) + { + return visitor.Visit(this); + } - public static SqlUndefinedLiteral Create() => SqlUndefinedLiteral.Singleton; + public static SqlUndefinedLiteral Create() + { + return SqlUndefinedLiteral.Singleton; + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlWhereClause.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlWhereClause.cs index 3a6ecbb7b..96056591e 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/SqlWhereClause.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/SqlWhereClause.cs @@ -22,12 +22,24 @@ namespace Microsoft.Azure.Cosmos.SqlObjects public SqlScalarExpression FilterExpression { get; } - public static SqlWhereClause Create(SqlScalarExpression filterExpression) => new SqlWhereClause(filterExpression); + public static SqlWhereClause Create(SqlScalarExpression filterExpression) + { + return new SqlWhereClause(filterExpression); + } - public override void Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override void Accept(SqlObjectVisitor visitor) + { + visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor) => visitor.Visit(this); + public override TResult Accept(SqlObjectVisitor visitor) + { + return visitor.Visit(this); + } - public override TResult Accept(SqlObjectVisitor visitor, T input) => visitor.Visit(this, input); + public override TResult Accept(SqlObjectVisitor visitor, T input) + { + return visitor.Visit(this, input); + } } } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlCollectionExpressionVisitor{TArg,TResult}.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlCollectionExpressionVisitor{TArg,TResult}.cs index cd9f69e74..b2bf09373 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlCollectionExpressionVisitor{TArg,TResult}.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlCollectionExpressionVisitor{TArg,TResult}.cs @@ -4,10 +4,6 @@ namespace Microsoft.Azure.Cosmos.SqlObjects.Visitors { - using System; - using System.Collections.Generic; - using System.Text; - #if INTERNAL #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable SA1600 // Elements should be documented diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectObfuscator.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectObfuscator.cs index 78ca5eea7..07b5f5038 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectObfuscator.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectObfuscator.cs @@ -409,7 +409,7 @@ namespace Microsoft.Azure.Cosmos.SqlObjects.Visitors || (value.IsInteger && (Number64.ToLong(value) == long.MinValue)) || (value.IsInteger && (Math.Abs(Number64.ToLong(value)) < 100)) || (value.IsDouble && (Math.Abs(Number64.ToDouble(value)) < 100) && ((long)Number64.ToDouble(value) == Number64.ToDouble(value))) - || (value.IsDouble && (Math.Abs(Number64.ToDouble(value)) <= Double.Epsilon))) + || (value.IsDouble && (Math.Abs(Number64.ToDouble(value)) <= double.Epsilon))) { obfuscatedNumber = value; } diff --git a/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectTextSerializer.cs b/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectTextSerializer.cs index ab4ced7c6..f0df171a0 100644 --- a/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectTextSerializer.cs +++ b/Microsoft.Azure.Cosmos/src/SqlObjects/Visitors/SqlObjectTextSerializer.cs @@ -642,7 +642,7 @@ namespace Microsoft.Azure.Cosmos.SqlObjects.Visitors } } - unsafe private static void WriteNumber64(StringBuilder stringBuilder, Number64 value) + private static unsafe void WriteNumber64(StringBuilder stringBuilder, Number64 value) { const int MaxNumberLength = 32; Span buffer = stackalloc byte[MaxNumberLength]; @@ -671,7 +671,7 @@ namespace Microsoft.Azure.Cosmos.SqlObjects.Visitors } } - unsafe private static void WriteEscapedString(StringBuilder stringBuilder, ReadOnlySpan unescapedString) + private static unsafe void WriteEscapedString(StringBuilder stringBuilder, ReadOnlySpan unescapedString) { while (!unescapedString.IsEmpty) { @@ -743,7 +743,7 @@ namespace Microsoft.Azure.Cosmos.SqlObjects.Visitors break; default: - char wideCharToEscape = (char)character; + char wideCharToEscape = character; // We got a control character (U+0000 through U+001F). stringBuilder.Append('\\'); stringBuilder.Append('u'); diff --git a/Microsoft.Azure.Cosmos/src/TaskHelper.cs b/Microsoft.Azure.Cosmos/src/TaskHelper.cs index a82e8f091..bb24facf4 100644 --- a/Microsoft.Azure.Cosmos/src/TaskHelper.cs +++ b/Microsoft.Azure.Cosmos/src/TaskHelper.cs @@ -13,7 +13,7 @@ namespace Microsoft.Azure.Cosmos /// internal static class TaskHelper { - static public Task InlineIfPossibleAsync(Func function, IRetryPolicy retryPolicy, CancellationToken cancellationToken = default(CancellationToken)) + static public Task InlineIfPossibleAsync(Func function, IRetryPolicy retryPolicy, CancellationToken cancellationToken = default) { if (SynchronizationContext.Current == null) { @@ -50,7 +50,7 @@ namespace Microsoft.Azure.Cosmos } #pragma warning disable VSTHRD200 // Use "Async" suffix for async methods - static public Task InlineIfPossible(Func> function, IRetryPolicy retryPolicy, CancellationToken cancellationToken = default(CancellationToken)) + static public Task InlineIfPossible(Func> function, IRetryPolicy retryPolicy, CancellationToken cancellationToken = default) #pragma warning restore VSTHRD200 // Use "Async" suffix for async methods { if (SynchronizationContext.Current == null) diff --git a/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheel.cs b/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheel.cs index e4622c740..b95ccdac1 100644 --- a/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheel.cs +++ b/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheel.cs @@ -46,7 +46,7 @@ namespace Microsoft.Azure.Cosmos TimeSpan resolution, int buckets) { - return new Timers.TimerWheelCore(resolution, buckets); + return new Timers.TimerWheelCore(resolution, buckets); } } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelCore.cs b/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelCore.cs index ba65dbadf..d5a545254 100644 --- a/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelCore.cs +++ b/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelCore.cs @@ -16,7 +16,7 @@ namespace Microsoft.Azure.Cosmos.Timers private readonly ConcurrentDictionary> timers; private readonly int resolutionInTicks; private readonly int resolutionInMs; - private readonly int buckets; + private readonly int buckets; private readonly Timer timer; private readonly object subscriptionLock; private readonly object timerConcurrencyLock; @@ -119,7 +119,7 @@ namespace Microsoft.Azure.Cosmos.Timers } } - public void OnTimer(Object stateInfo) + public void OnTimer(object stateInfo) { lock (this.timerConcurrencyLock) { diff --git a/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelTimerCore.cs b/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelTimerCore.cs index 9763cc7e9..198bb79c6 100644 --- a/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelTimerCore.cs +++ b/Microsoft.Azure.Cosmos/src/TimerWheel/TimerWheelTimerCore.cs @@ -10,14 +10,14 @@ namespace Microsoft.Azure.Cosmos.Timers #nullable enable internal sealed class TimerWheelTimerCore : TimerWheelTimer { - private static object completedObject = new object(); + private static readonly object completedObject = new object(); private readonly TaskCompletionSource taskCompletionSource; - private readonly Object memberLock; + private readonly object memberLock; private readonly TimerWheel timerWheel; private bool timerStarted = false; internal TimerWheelTimerCore( - TimeSpan timeoutPeriod, + TimeSpan timeoutPeriod, TimerWheel timerWheel) { if (timeoutPeriod.Ticks == 0) @@ -28,7 +28,7 @@ namespace Microsoft.Azure.Cosmos.Timers this.timerWheel = timerWheel ?? throw new ArgumentNullException(nameof(timerWheel)); this.Timeout = timeoutPeriod; this.taskCompletionSource = new TaskCompletionSource(); - this.memberLock = new Object(); + this.memberLock = new object(); } public override TimeSpan Timeout { get; } diff --git a/Microsoft.Azure.Cosmos/src/Tracing/NoOpTrace.cs b/Microsoft.Azure.Cosmos/src/Tracing/NoOpTrace.cs index 35d0671bf..ff990cb6c 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/NoOpTrace.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/NoOpTrace.cs @@ -6,7 +6,6 @@ namespace Microsoft.Azure.Cosmos.Tracing { using System; using System.Collections.Generic; - using System.Diagnostics; internal sealed class NoOpTrace : ITrace { @@ -49,10 +48,13 @@ namespace Microsoft.Azure.Cosmos.Tracing string name, string memberName = "", string sourceFilePath = "", - int sourceLineNumber = 0) => this.StartChild( - name, - component: this.Component, - level: TraceLevel.Info); + int sourceLineNumber = 0) + { + return this.StartChild( +name, +component: this.Component, +level: TraceLevel.Info); + } public ITrace StartChild( string name, diff --git a/Microsoft.Azure.Cosmos/src/Tracing/Trace.cs b/Microsoft.Azure.Cosmos/src/Tracing/Trace.cs index 923d291b9..fd3f42fb9 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/Trace.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/Trace.cs @@ -63,13 +63,16 @@ namespace Microsoft.Azure.Cosmos.Tracing string name, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", - [CallerLineNumber] int sourceLineNumber = 0) => this.StartChild( - name, - level: TraceLevel.Verbose, - component: this.Component, - memberName: memberName, - sourceFilePath: sourceFilePath, - sourceLineNumber: sourceLineNumber); + [CallerLineNumber] int sourceLineNumber = 0) + { + return this.StartChild( +name, +level: TraceLevel.Verbose, +component: this.Component, +memberName: memberName, +sourceFilePath: sourceFilePath, +sourceLineNumber: sourceLineNumber); + } public ITrace StartChild( string name, @@ -89,10 +92,13 @@ namespace Microsoft.Azure.Cosmos.Tracing return child; } - public static Trace GetRootTrace(string name) => Trace.GetRootTrace( - name, - component: TraceComponent.Unknown, - level: TraceLevel.Verbose); + public static Trace GetRootTrace(string name) + { + return Trace.GetRootTrace( +name, +component: TraceComponent.Unknown, +level: TraceLevel.Verbose); + } public static Trace GetRootTrace( string name, @@ -100,15 +106,24 @@ namespace Microsoft.Azure.Cosmos.Tracing TraceLevel level, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", - [CallerLineNumber] int sourceLineNumber = 0) => new Trace( - name: name, - callerInfo: new CallerInfo(memberName, sourceFilePath, sourceLineNumber), - level: level, - component: component, - parent: null); + [CallerLineNumber] int sourceLineNumber = 0) + { + return new Trace( +name: name, +callerInfo: new CallerInfo(memberName, sourceFilePath, sourceLineNumber), +level: level, +component: component, +parent: null); + } - public void AddDatum(string key, ITraceDatum traceDatum) => this.data.Add(key, traceDatum); + public void AddDatum(string key, ITraceDatum traceDatum) + { + this.data.Add(key, traceDatum); + } - public void AddDatum(string key, object value) => this.data.Add(key, value); + public void AddDatum(string key, object value) + { + this.data.Add(key, value); + } } } diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/CosmosDiagnosticsTraceDatum.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/CosmosDiagnosticsTraceDatum.cs index 66aa70fd0..f764cc3ff 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/CosmosDiagnosticsTraceDatum.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/CosmosDiagnosticsTraceDatum.cs @@ -16,6 +16,9 @@ namespace Microsoft.Azure.Cosmos.Tracing.TraceData this.CosmosDiagnostics = cosmosDiagnostics ?? throw new ArgumentNullException(nameof(cosmosDiagnostics)); } - public void Accept(ITraceDatumVisitor traceDatumVisitor) => traceDatumVisitor.Visit(this); + public void Accept(ITraceDatumVisitor traceDatumVisitor) + { + traceDatumVisitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/QueryMetricsTraceDatum.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/QueryMetricsTraceDatum.cs index 5e954f6c6..b1bb1aff2 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/QueryMetricsTraceDatum.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/QueryMetricsTraceDatum.cs @@ -16,6 +16,9 @@ namespace Microsoft.Azure.Cosmos.Tracing.TraceData public QueryMetrics QueryMetrics { get; } - public void Accept(ITraceDatumVisitor traceDatumVisitor) => traceDatumVisitor.Visit(this); + public void Accept(ITraceDatumVisitor traceDatumVisitor) + { + traceDatumVisitor.Visit(this); + } } } diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs index 6af4cea69..55f047269 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs @@ -7,7 +7,6 @@ namespace Microsoft.Azure.Cosmos.Tracing using System; using System.Collections.Generic; using System.IO; - using System.Linq; using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Cosmos.Json; using Microsoft.Azure.Cosmos.Tracing.TraceData; diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceTextWriter.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceTextWriter.cs index 9cde258e2..d7f6723df 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceTextWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceTextWriter.cs @@ -288,7 +288,10 @@ namespace Microsoft.Azure.Cosmos.Tracing this.toStringValue = queryMetricsTraceDatum.QueryMetrics.ToString(); } - public override string ToString() => this.toStringValue; + public override string ToString() + { + return this.toStringValue; + } public void Visit(CosmosDiagnosticsTraceDatum cosmosDiagnosticsTraceDatum) { @@ -363,39 +366,42 @@ namespace Microsoft.Azure.Cosmos.Tracing public string Blank { get; } - public static AsciiTreeIndents Create(AsciiTreeCharacters asciiTreeCharacters) => new AsciiTreeIndents( - child: new string( - new char[] - { + public static AsciiTreeIndents Create(AsciiTreeCharacters asciiTreeCharacters) + { + return new AsciiTreeIndents( +child: new string( +new char[] +{ asciiTreeCharacters.Child, asciiTreeCharacters.Dash, asciiTreeCharacters.Dash, asciiTreeCharacters.Blank - }), - parent: new string( - new char[] - { +}), +parent: new string( +new char[] +{ asciiTreeCharacters.Parent, asciiTreeCharacters.Blank, asciiTreeCharacters.Blank, asciiTreeCharacters.Blank - }), - last: new string( - new char[] - { +}), +last: new string( +new char[] +{ asciiTreeCharacters.Last, asciiTreeCharacters.Dash, asciiTreeCharacters.Dash, asciiTreeCharacters.Blank - }), - blank: new string( - new char[] - { +}), +blank: new string( +new char[] +{ asciiTreeCharacters.Blank, asciiTreeCharacters.Blank, asciiTreeCharacters.Blank, asciiTreeCharacters.Blank - })); +})); + } } } } diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.cs index 5f1c53ee1..9a1d6d9e3 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.Cosmos.Tracing { - using System; using System.IO; using System.Text; using Microsoft.Azure.Cosmos.Json; @@ -15,15 +14,21 @@ namespace Microsoft.Azure.Cosmos.Tracing TextWriter writer, ITrace trace, TraceLevel level = TraceLevel.Verbose, - AsciiType asciiType = AsciiType.Default) => TraceTextWriter.WriteTrace( - writer, - trace, - level, - asciiType); + AsciiType asciiType = AsciiType.Default) + { + TraceTextWriter.WriteTrace( +writer, +trace, +level, +asciiType); + } public static void WriteTrace( IJsonWriter writer, - ITrace trace) => TraceJsonWriter.WriteTrace(writer, trace); + ITrace trace) + { + TraceJsonWriter.WriteTrace(writer, trace); + } public static string TraceToText( ITrace trace, diff --git a/Microsoft.Azure.Cosmos/src/Util/Extensions.cs b/Microsoft.Azure.Cosmos/src/Util/Extensions.cs index ca29a2ae8..3f132cb63 100644 --- a/Microsoft.Azure.Cosmos/src/Util/Extensions.cs +++ b/Microsoft.Azure.Cosmos/src/Util/Extensions.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.Cosmos { using System; - using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -49,7 +48,7 @@ namespace Microsoft.Azure.Cosmos if (string.IsNullOrEmpty(value)) { - return default(T); + return default; } if (typeof(T) == typeof(double)) diff --git a/Microsoft.Azure.Cosmos/src/Util/ServicePointAccessor.cs b/Microsoft.Azure.Cosmos/src/Util/ServicePointAccessor.cs index fc642ff05..14e415f00 100644 --- a/Microsoft.Azure.Cosmos/src/Util/ServicePointAccessor.cs +++ b/Microsoft.Azure.Cosmos/src/Util/ServicePointAccessor.cs @@ -15,7 +15,7 @@ namespace Microsoft.Azure.Cosmos internal class ServicePointAccessor { // WebAssembly detection - private static bool IsBrowser = RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) || RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")); + private static readonly bool IsBrowser = RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) || RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")); private readonly ServicePoint servicePoint; @@ -41,7 +41,7 @@ namespace Microsoft.Azure.Cosmos { // Workaround for WebAssembly. // WebAssembly currently throws a SynchronizationLockException and not a PlatformNotSupportedException. - return; + return; } try diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/AsyncCacheTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/AsyncCacheTest.cs index 9b4e4220a..60f95e0ba 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/AsyncCacheTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/AsyncCacheTest.cs @@ -192,7 +192,6 @@ namespace Microsoft.Azure.Cosmos.Tests // neither task is complete at this point. Assert.IsFalse(getTask2.IsCompleted); - Assert.IsFalse(getTask1.IsCompleted); try { diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/TimerWheel/TimerWheelCoreTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/TimerWheel/TimerWheelCoreTests.cs index 5ea7333a5..789c2168f 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/TimerWheel/TimerWheelCoreTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/TimerWheel/TimerWheelCoreTests.cs @@ -126,7 +126,8 @@ namespace Microsoft.Azure.Cosmos.Tests Stopwatch stopwatch = Stopwatch.StartNew(); await Task.WhenAll(timer.StartTimerAsync(), timer2.StartTimerAsync()); stopwatch.Stop(); - Assert.IsTrue(stopwatch.ElapsedMilliseconds >= timerTimeout - resolution && stopwatch.ElapsedMilliseconds <= timerTimeout + resolution); + Assert.IsTrue(stopwatch.ElapsedMilliseconds >= timerTimeout - resolution, $"{stopwatch.ElapsedMilliseconds} >= {timerTimeout - resolution}, timerTimeout: {timerTimeout}, resolution: {resolution}"); + Assert.IsTrue(stopwatch.ElapsedMilliseconds <= timerTimeout + resolution, $"{stopwatch.ElapsedMilliseconds} <= {timerTimeout + resolution}, timerTimeout: {timerTimeout}, resolution: {resolution}"); } [TestMethod]