Skip to content

Commit 1432e1d

Browse files
authored
Merge pull request #901 from microsoftgraph/andrueastman/lintCleanup
chore: lint code and keep consistent with other code.
2 parents 0364e8c + d323d37 commit 1432e1d

File tree

97 files changed

+1188
-599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1188
-599
lines changed

.editorconfig

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
2+
###############################
3+
# Core EditorConfig Options #
4+
###############################
5+
# All files
6+
[*]
7+
indent_style = space
8+
# Code files
9+
[*.{cs,csx,vb,vbx}]
10+
indent_size = 4
11+
insert_final_newline = true
12+
charset = utf-8-bom
13+
###############################
14+
# .NET Coding Conventions #
15+
###############################
16+
[*.{cs,vb}]
17+
# Organize usings
18+
dotnet_sort_system_directives_first = true
19+
# this. preferences
20+
dotnet_style_qualification_for_field = false:silent
21+
dotnet_style_qualification_for_property = false:silent
22+
dotnet_style_qualification_for_method = false:silent
23+
dotnet_style_qualification_for_event = false:silent
24+
# Language keywords vs BCL types preferences
25+
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
26+
dotnet_style_predefined_type_for_member_access = true:silent
27+
# Parentheses preferences
28+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
29+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
30+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
31+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
32+
# Modifier preferences
33+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
34+
dotnet_style_readonly_field = true:suggestion
35+
# Expression-level preferences
36+
dotnet_style_object_initializer = true:suggestion
37+
dotnet_style_collection_initializer = true:suggestion
38+
dotnet_style_explicit_tuple_names = true:suggestion
39+
dotnet_style_null_propagation = true:suggestion
40+
dotnet_style_coalesce_expression = true:suggestion
41+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
42+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
43+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
44+
dotnet_style_prefer_auto_properties = true:silent
45+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
46+
dotnet_style_prefer_conditional_expression_over_return = true:silent
47+
###############################
48+
# Naming Conventions #
49+
###############################
50+
# Style Definitions
51+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
52+
# Use PascalCase for constant fields
53+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
54+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
55+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
56+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
57+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
58+
dotnet_naming_symbols.constant_fields.required_modifiers = const
59+
###############################
60+
# C# Coding Conventions #
61+
###############################
62+
[*.cs]
63+
# var preferences
64+
csharp_style_var_for_built_in_types = true:silent
65+
csharp_style_var_when_type_is_apparent = true:silent
66+
csharp_style_var_elsewhere = true:silent
67+
# Expression-bodied members
68+
csharp_style_expression_bodied_methods = false:silent
69+
csharp_style_expression_bodied_constructors = false:silent
70+
csharp_style_expression_bodied_operators = false:silent
71+
csharp_style_expression_bodied_properties = true:silent
72+
csharp_style_expression_bodied_indexers = true:silent
73+
csharp_style_expression_bodied_accessors = true:silent
74+
# Pattern matching preferences
75+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
76+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
77+
# Null-checking preferences
78+
csharp_style_throw_expression = true:suggestion
79+
csharp_style_conditional_delegate_call = true:suggestion
80+
# Modifier preferences
81+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
82+
# Expression-level preferences
83+
csharp_prefer_braces = true:silent
84+
csharp_style_deconstructed_variable_declaration = true:suggestion
85+
csharp_prefer_simple_default_expression = true:suggestion
86+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
87+
csharp_style_inlined_variable_declaration = true:suggestion
88+
###############################
89+
# C# Formatting Rules #
90+
###############################
91+
# New line preferences
92+
csharp_new_line_before_open_brace = all
93+
csharp_new_line_before_else = true
94+
csharp_new_line_before_catch = true
95+
csharp_new_line_before_finally = true
96+
csharp_new_line_before_members_in_object_initializers = true
97+
csharp_new_line_before_members_in_anonymous_types = true
98+
csharp_new_line_between_query_expression_clauses = true
99+
# Indentation preferences
100+
csharp_indent_case_contents = true
101+
csharp_indent_switch_labels = true
102+
csharp_indent_labels = flush_left
103+
# Space preferences
104+
csharp_space_after_cast = false
105+
csharp_space_after_keywords_in_control_flow_statements = true
106+
csharp_space_between_method_call_parameter_list_parentheses = false
107+
csharp_space_between_method_declaration_parameter_list_parentheses = false
108+
csharp_space_between_parentheses = false
109+
csharp_space_before_colon_in_inheritance_clause = true
110+
csharp_space_after_colon_in_inheritance_clause = true
111+
csharp_space_around_binary_operators = before_and_after
112+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
113+
csharp_space_between_method_call_name_and_opening_parenthesis = false
114+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
115+
# Wrapping preferences
116+
csharp_preserve_single_line_statements = true
117+
csharp_preserve_single_line_blocks = false
118+
###############################
119+
# VB Coding Conventions #
120+
###############################
121+
[*.vb]
122+
# Modifier preferences
123+
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
124+
125+
[*.json]
126+
indent_size = 2
127+
insert_final_newline = true

.github/workflows/validatePullRequest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- name: Install needed dotnet workloads
4242
run: dotnet workload install android macos ios maccatalyst
4343

44+
- name: Lint the code
45+
run: dotnet format --verify-no-changes
46+
4447
- name: Restore nuget dependencies
4548
run: dotnet restore ${{ env.solutionName }}
4649

src/Microsoft.Graph.Core/Authentication/AzureIdentityAccessTokenProvider.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
// ------------------------------------------------------------------------------
1+
// ------------------------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

5-
using Azure.Core;
6-
using Microsoft.Kiota.Abstractions.Authentication;
75
using System;
86
using System.Linq;
7+
using Azure.Core;
8+
using Microsoft.Kiota.Abstractions.Authentication;
99

1010
namespace Microsoft.Graph.Authentication;
1111

1212
/// <summary>
1313
/// An overload of the Access Token Provider that has the defaults for Microsoft Graph.
1414
/// </summary>
15-
public class AzureIdentityAccessTokenProvider : Microsoft.Kiota.Authentication.Azure.AzureIdentityAccessTokenProvider {
15+
public class AzureIdentityAccessTokenProvider : Microsoft.Kiota.Authentication.Azure.AzureIdentityAccessTokenProvider
16+
{
1617
/// <inheritdoc/>
17-
public AzureIdentityAccessTokenProvider(TokenCredential credential, string [] allowedHosts = null, Microsoft.Kiota.Authentication.Azure.ObservabilityOptions observabilityOptions = null, bool isCaeEnabled = true, params string[] scopes)
18-
: base(credential, allowedHosts, observabilityOptions, isCaeEnabled, scopes) {
19-
if(!allowedHosts?.Any() ?? true)
18+
public AzureIdentityAccessTokenProvider(TokenCredential credential, string[] allowedHosts = null, Microsoft.Kiota.Authentication.Azure.ObservabilityOptions observabilityOptions = null, bool isCaeEnabled = true, params string[] scopes)
19+
: base(credential, allowedHosts, observabilityOptions, isCaeEnabled, scopes)
20+
{
21+
if (!allowedHosts?.Any() ?? true)
2022
AllowedHostsValidator = new AllowedHostsValidator(new string[] { "graph.microsoft.com", "graph.microsoft.us", "dod-graph.microsoft.us", "graph.microsoft.de", "microsoftgraph.chinacloudapi.cn", "canary.graph.microsoft.com", "graph.microsoft-ppe.com" });
21-
}
23+
}
2224

2325
/// <inheritdoc/>
2426
[Obsolete("This constructor is obsolete and will be removed in a future version. Use the constructor that takes an isCaeEnabled parameter instead.")]

src/Microsoft.Graph.Core/Authentication/AzureIdentityAuthenticationProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ------------------------------------------------------------------------------
1+
// ------------------------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

@@ -22,7 +22,7 @@ public class AzureIdentityAuthenticationProvider : BaseBearerTokenAuthentication
2222
/// <param name="isCaeEnabled">Determines if the Continuous Access Evaluation (CAE) is enabled.</param>
2323
public AzureIdentityAuthenticationProvider(TokenCredential credential, string[] allowedHosts = null, Microsoft.Kiota.Authentication.Azure.ObservabilityOptions observabilityOptions = null, bool isCaeEnabled = true, params string[] scopes) : base(new AzureIdentityAccessTokenProvider(credential, allowedHosts, observabilityOptions, isCaeEnabled, scopes))
2424
{
25-
}
25+
}
2626
/// <summary>
2727
/// The <see cref="AzureIdentityAuthenticationProvider"/> constructor
2828
/// </summary>
@@ -33,5 +33,5 @@ public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]
3333
[Obsolete("Use the constructor that takes an isCaeEnabled parameter instead.")]
3434
public AzureIdentityAuthenticationProvider(TokenCredential credential, string[] allowedHosts = null, Microsoft.Kiota.Authentication.Azure.ObservabilityOptions observabilityOptions = null, params string[] scopes) : this(credential, allowedHosts, observabilityOptions, true, scopes)
3535
{
36-
}
37-
}
36+
}
37+
}

src/Microsoft.Graph.Core/CoreConstants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ------------------------------------------------------------------------------
1+
// ------------------------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

@@ -21,7 +21,7 @@ public static class Headers
2121
{
2222
/// Authorization bearer.
2323
public const string Bearer = "Bearer";
24-
24+
2525
/// SDK Version header
2626
public const string SdkVersionHeaderName = "SdkVersion";
2727

src/Microsoft.Graph.Core/Exceptions/ClientException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Microsoft.Graph
66
{
77
using System;
88
using Microsoft.Kiota.Abstractions;
9-
9+
1010
/// <summary>
1111
/// Graph client exception.
1212
/// </summary>

src/Microsoft.Graph.Core/Exceptions/ErrorConstants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal static class Messages
3636
internal static string BaseUrlMissing = "Base URL cannot be null or empty.";
3737

3838
internal static string InvalidTypeForDateConverter = "DateConverter can only serialize objects of type Date.";
39-
39+
4040
internal static string InvalidTypeForDateTimeOffsetConverter = "DateTimeOffsetConverter can only serialize objects of type DateTimeOffset.";
4141

4242
internal static string LocationHeaderNotSetOnRedirect = "Location header not present in redirection response.";
@@ -76,7 +76,7 @@ internal static class Messages
7676
internal static string NullValue = "{0} cannot be null.";
7777

7878
internal static string UnexpectedMsalException = "Unexpected exception returned from MSAL.";
79-
79+
8080
internal static string UnexpectedException = "Unexpected exception occured while authenticating the request.";
8181

8282
internal static string MissingRetryAfterHeader = "Missing retry after header.";

src/Microsoft.Graph.Core/Exceptions/ServiceException.cs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// ------------------------------------------------------------------------------
1+
// ------------------------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

55
namespace Microsoft.Graph
66
{
7-
using Microsoft.Kiota.Abstractions;
8-
using Microsoft.Kiota.Abstractions.Serialization;
97
using System;
108
using System.Collections.Generic;
9+
using Microsoft.Kiota.Abstractions;
10+
using Microsoft.Kiota.Abstractions.Serialization;
1111

1212
/// <summary>
1313
/// Graph service exception.
@@ -48,7 +48,7 @@ public ServiceException(string message, System.Net.Http.Headers.HttpResponseHead
4848
/// <param name="rawResponseBody">The raw JSON response body.</param>
4949
public ServiceException(string message,
5050
System.Net.Http.Headers.HttpResponseHeaders responseHeaders,
51-
int statusCode,
51+
int statusCode,
5252
string rawResponseBody,
5353
Exception innerException = null)
5454
: this(message, responseHeaders, statusCode, innerException)
@@ -61,15 +61,24 @@ public ServiceException(string message,
6161
/// <summary>
6262
/// The HTTP response headers from the response.
6363
/// </summary>
64-
public new System.Net.Http.Headers.HttpResponseHeaders ResponseHeaders { get; private set; }
65-
64+
public new System.Net.Http.Headers.HttpResponseHeaders ResponseHeaders
65+
{
66+
get; private set;
67+
}
68+
6669
/// <summary>
6770
/// Provide the raw JSON response body.
6871
/// </summary>
69-
public string RawResponseBody { get; private set; }
72+
public string RawResponseBody
73+
{
74+
get; private set;
75+
}
7076

7177
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
72-
public IDictionary<string, object> AdditionalData { get; set; }
78+
public IDictionary<string, object> AdditionalData
79+
{
80+
get; set;
81+
}
7382

7483
/// <summary>
7584
/// Checks if a given error code has been returned in the response at any level in the error stack.
@@ -82,13 +91,13 @@ public bool IsMatch(string errorCode)
8291
{
8392
throw new ArgumentException("errorCode cannot be null or empty", nameof(errorCode));
8493
}
85-
86-
if (RawResponseBody is not null && RawResponseBody.IndexOf(errorCode,StringComparison.OrdinalIgnoreCase) >= 0)
94+
95+
if (RawResponseBody is not null && RawResponseBody.IndexOf(errorCode, StringComparison.OrdinalIgnoreCase) >= 0)
8796
{
8897
return true;
8998
}
90-
91-
if (!string.IsNullOrWhiteSpace(Message) && Message.IndexOf(errorCode,StringComparison.OrdinalIgnoreCase) >= 0)
99+
100+
if (!string.IsNullOrWhiteSpace(Message) && Message.IndexOf(errorCode, StringComparison.OrdinalIgnoreCase) >= 0)
92101
{
93102
return true;
94103
}
@@ -125,4 +134,4 @@ public void Serialize(ISerializationWriter writer)
125134
writer.WriteAdditionalData(AdditionalData);
126135
}
127136
}
128-
}
137+
}

src/Microsoft.Graph.Core/Extensions/HttpRequestMessageExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ------------------------------------------------------------------------------
1+
// ------------------------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

@@ -33,7 +33,7 @@ internal static FeatureFlag GetFeatureFlags(this HttpRequestMessage httpRequestM
3333

3434
return featureFlag;
3535
}
36-
36+
3737
/// <summary>
3838
/// Gets a <see cref="GraphRequestContext"/> from <see cref="HttpRequestMessage"/>
3939
/// </summary>

src/Microsoft.Graph.Core/Extensions/IDecryptableContentExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// ------------------------------------------------------------------------------
1+
// ------------------------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

55
namespace Microsoft.Graph
66
{
7-
using System.Text.Json;
87
using System;
98
using System.IO;
109
using System.Security.Cryptography;
1110
using System.Security.Cryptography.X509Certificates;
1211
using System.Text;
12+
using System.Text.Json;
1313
using System.Threading.Tasks;
1414
using Microsoft.Kiota.Abstractions.Serialization;
1515
using Microsoft.Kiota.Serialization.Json;

0 commit comments

Comments
 (0)