Skip to content

Commit 9236b6f

Browse files
committed
Add code style conventions
1 parent 517e332 commit 9236b6f

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

.editorconfig

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# EditorConfig is awesome:
2+
http://EditorConfig.org
3+
4+
# top-most EditorConfig file
5+
root = true
6+
# Don't use tabs for indentation.
7+
[*]
8+
indent_style = space
9+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
10+
[*.cs]
11+
indent_size = 4
12+
[*.json]
13+
indent_size = 2
14+
15+
[*.cs]
16+
# Avoid "this." and "Me." if not necessary
17+
dotnet_style_qualification_for_field = false:suggestion
18+
dotnet_style_qualification_for_property = false:suggestion
19+
dotnet_style_qualification_for_method = false:suggestion
20+
dotnet_style_qualification_for_event = false:suggestion
21+
22+
# Use language keywords instead of framework type names for type references
23+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
24+
dotnet_style_predefined_type_for_member_access = true:suggestion
25+
26+
# Suggest more modern language features when available
27+
dotnet_style_object_initializer = true:suggestion
28+
dotnet_style_collection_initializer = true:suggestion
29+
dotnet_style_coalesce_expression = true:suggestion
30+
dotnet_style_null_propagation = true:suggestion
31+
dotnet_style_explicit_tuple_names = true:suggestion
32+
33+
# Prefer "var" everywhere
34+
csharp_style_var_for_built_in_types = true:suggestion
35+
csharp_style_var_when_type_is_apparent = true:suggestion
36+
csharp_style_var_elsewhere = true:suggestion
37+
38+
# Prefer method-like constructs to have a block body
39+
csharp_style_expression_bodied_methods = false:none
40+
csharp_style_expression_bodied_constructors = false:none
41+
csharp_style_expression_bodied_operators = false:none
42+
43+
# Prefer property-like constructs to have an expression-body
44+
csharp_style_expression_bodied_properties = true:none
45+
csharp_style_expression_bodied_indexers = true:none
46+
csharp_style_expression_bodied_accessors = true:none
47+
48+
# Suggest more modern language features when available
49+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
50+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
51+
csharp_style_inlined_variable_declaration = true:suggestion
52+
csharp_style_throw_expression = true:suggestion
53+
csharp_style_conditional_delegate_call = true:suggestion

Contentful.Core/ContentfulManagementClient.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Contentful.Core
1919
public class ContentfulManagementClient : ContentfulClientBase, IContentfulManagementClient
2020
{
2121
private readonly string _baseUrl = "https://api.contentful.com/spaces/";
22-
22+
2323
/// <summary>
2424
/// Initializes a new instance of the <see cref="ContentfulManagementClient"/> class.
2525
/// The main class for interaction with the contentful deliver and preview APIs.
@@ -43,7 +43,7 @@ public ContentfulManagementClient(HttpClient httpClient, IOptions<ContentfulOpti
4343
/// </summary>
4444
/// <param name="httpClient">The HttpClient of your application.</param>
4545
/// <param name="options">The <see cref="ContentfulOptions"/> used for this client.</param>
46-
public ContentfulManagementClient(HttpClient httpClient, ContentfulOptions options):
46+
public ContentfulManagementClient(HttpClient httpClient, ContentfulOptions options) :
4747
this(httpClient, new OptionsWrapper<ContentfulOptions>(options))
4848
{
4949

@@ -57,7 +57,7 @@ public ContentfulManagementClient(HttpClient httpClient, ContentfulOptions optio
5757
/// <param name="spaceId">The id of the space to fetch content from.</param>
5858
/// If this is set to true the preview API key needs to be used for <paramref name="deliveryApiKey"/>
5959
/// </param>
60-
public ContentfulManagementClient(HttpClient httpClient, string managementApiKey, string spaceId):
60+
public ContentfulManagementClient(HttpClient httpClient, string managementApiKey, string spaceId) :
6161
this(httpClient, new OptionsWrapper<ContentfulOptions>(new ContentfulOptions()
6262
{
6363
ManagementApiKey = managementApiKey,
@@ -210,7 +210,7 @@ public ContentfulManagementClient(HttpClient httpClient, string managementApiKey
210210
/// <exception cref="ArgumentException">Thrown if the id of the content type is not set.</exception>
211211
public async Task<ContentType> CreateOrUpdateContentTypeAsync(ContentType contentType, string spaceId = null, int? version = null, CancellationToken cancellationToken = default(CancellationToken))
212212
{
213-
if(contentType.SystemProperties?.Id == null)
213+
if (contentType.SystemProperties?.Id == null)
214214
{
215215
throw new ArgumentException("The id of the content type must be set.", nameof(contentType));
216216
}
@@ -391,7 +391,7 @@ public ContentfulManagementClient(HttpClient httpClient, string managementApiKey
391391

392392
AddVersionHeader(version);
393393

394-
var res = await PutAsync($"{_baseUrl}{spaceId ?? _options.SpaceId}/content_types/{contentTypeId}/editor_interface",
394+
var res = await PutAsync($"{_baseUrl}{spaceId ?? _options.SpaceId}/content_types/{contentTypeId}/editor_interface",
395395
ConvertObjectToJsonStringContent(new { controls = editorInterface.Controls }), cancellationToken).ConfigureAwait(false);
396396

397397
RemoveVersionHeader();
@@ -1557,7 +1557,7 @@ public ContentfulManagementClient(HttpClient httpClient, string managementApiKey
15571557
/// <exception cref="ContentfulException">There was an error when communicating with the Contentful API.</exception>
15581558
public async Task<ApiKey> CreateApiKeyAsync(string name, string description, string spaceId = null, CancellationToken cancellationToken = default(CancellationToken))
15591559
{
1560-
if(string.IsNullOrEmpty(name))
1560+
if (string.IsNullOrEmpty(name))
15611561
{
15621562
throw new ArgumentException("The name of the api key must be set.", nameof(name));
15631563
}

0 commit comments

Comments
 (0)