Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 5b27513

Browse files
authored
Added .editorconfig and fixed style according to it (#621)
* added .editorconfig and fixed style according to it * add issue link to TODO for creator executor Co-authored-by: Dmitrii Korolev <dmkorolev@microsoft.com>
1 parent 1f8e00e commit 5b27513

File tree

53 files changed

+684
-612
lines changed

Some content is hidden

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

53 files changed

+684
-612
lines changed

.editorconfig

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
2+
root = true
3+
4+
# Don't use tabs for indentation.
5+
[*]
6+
indent_style = space
7+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
8+
9+
[*.cs]
10+
indent_size = 4
11+
charset = utf-8-bom
12+
13+
file_header_template =--------------------------------------------------------------------------\n <copyright file="{fileName}" company="Microsoft">\n Copyright (c) Microsoft Corporation. All rights reserved.\n </copyright>\n--------------------------------------------------------------------------
14+
15+
# use this. for all instance member access
16+
dotnet_style_qualification_for_field = true:error
17+
dotnet_style_qualification_for_property = true:error
18+
dotnet_style_qualification_for_method = true:error
19+
dotnet_style_qualification_for_event = true:error
20+
21+
# Sort using and Import directives with System.* appearing first
22+
dotnet_sort_system_directives_first = true
23+
dotnet_separate_import_directive_groups = false
24+
25+
# don't specify private/internal if it's default
26+
dotnet_style_require_accessibility_modifiers = omit_if_default:error
27+
28+
# Reusable naming style definitions
29+
dotnet_naming_style.camel_case.capitalization = camel_case
30+
dotnet_naming_style.pascal_case.capitalization = pascal_case
31+
32+
# Constants are PascalCase
33+
dotnet_naming_rule.constants_should_be_pascal_case.severity = error
34+
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
35+
dotnet_naming_rule.constants_should_be_pascal_case.style = pascal_case
36+
37+
dotnet_naming_symbols.constants.applicable_kinds = field, local
38+
dotnet_naming_symbols.constants.required_modifiers = const
39+
40+
# Static fields are PascalCase
41+
dotnet_naming_rule.static_fields_should_be_pascal_case.severity = error
42+
dotnet_naming_rule.static_fields_should_be_pascal_case.symbols = static_fields
43+
dotnet_naming_rule.static_fields_should_be_pascal_case.style = pascal_case
44+
45+
dotnet_naming_symbols.static_fields.applicable_kinds = field
46+
dotnet_naming_symbols.static_fields.applicable_accessibilities = *
47+
dotnet_naming_symbols.static_fields.required_modifiers = static
48+
49+
# Private instance private fields are camelCase
50+
dotnet_naming_rule.private_instance_fields_should_be_camel_case.severity = error
51+
dotnet_naming_rule.private_instance_fields_should_be_camel_case.symbols = private_instance_fields
52+
dotnet_naming_rule.private_instance_fields_should_be_camel_case.style = camel_case
53+
54+
dotnet_naming_symbols.private_instance_fields.applicable_kinds = field
55+
dotnet_naming_symbols.private_instance_fields.applicable_accessibilities = private
56+
57+
# Locals and parameters are camelCase
58+
dotnet_naming_rule.locals_should_be_camel_case.severity = error
59+
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
60+
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case
61+
62+
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
63+
64+
# Local functions are PascalCase
65+
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = error
66+
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
67+
dotnet_naming_rule.local_functions_should_be_pascal_case.style = pascal_case
68+
69+
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
70+
71+
# All public and internal members are PascalCase
72+
dotnet_naming_rule.public_members_should_be_pascal_case.severity = error
73+
dotnet_naming_rule.public_members_should_be_pascal_case.symbols = public_members
74+
dotnet_naming_rule.public_members_should_be_pascal_case.style = pascal_case
75+
76+
dotnet_naming_symbols.public_members.applicable_kinds = property, method, field, event, delegate
77+
dotnet_naming_symbols.public_members.applicable_accessibilities = public, internal
78+
79+
# let's not take responsibility for DotNetty problems (is external repo)
80+
[Proxy/DotNetty/**.cs]
81+
dotnet_analyzer_diagnostic.severity = none # disables most external analyzers
82+
dotnet_diagnostic.CS0628.severity = none # protected member in sealed class
83+
dotnet_diagnostic.CS0108.severity = none # hides inherited member, no "new"
84+
dotnet_diagnostic.CS1570.severity = none # xml comments: badly formed xml
85+
dotnet_diagnostic.CS1573.severity = none # xml comments: missing a parameter
86+
dotnet_diagnostic.CS1574.severity = none # xml comments: bad cref
87+
dotnet_diagnostic.CS1711.severity = none # xml comments: bad type param
88+
dotnet_diagnostic.CS4014.severity = none # awaitable call not awaited

src/ArmTemplates/Commands/Abstractions/CommandLineApplicationBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ public abstract class CommandLineApplicationBase : CommandLineApplication
77
{
88
protected CommandLineApplicationBase()
99
{
10-
SetupApplicationAndCommands();
10+
this.SetupApplicationAndCommands();
1111

1212
this.HelpOption();
1313

14-
OnExecute(async () => await ExecuteCommand());
14+
this.OnExecute(async () => await this.ExecuteCommand());
1515
}
1616

1717
protected abstract void SetupApplicationAndCommands();

src/ArmTemplates/Commands/Applications/CreateApplicationCommand.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@ namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Commands.Applica
1515
{
1616
public class CreateApplicationCommand : CommandLineApplicationBase
1717
{
18-
private CommandOption _appInsightsInstrumentationKey;
19-
private CommandOption _appInsightsName;
20-
private CommandOption _namedValueKeys;
21-
private CommandOption _apimNameValue;
22-
private CommandOption _configFile;
23-
private CommandOption _backendUrlConfigFile;
24-
private CommandOption _preferredAPIsForDeployment;
18+
CommandOption appInsightsInstrumentationKey;
19+
CommandOption appInsightsName;
20+
CommandOption namedValueKeys;
21+
CommandOption apimNameValue;
22+
CommandOption configFile;
23+
CommandOption backendUrlConfigFile;
24+
CommandOption preferredAPIsForDeployment;
2525

2626
public CreateApplicationCommand() : base()
2727
{
2828
}
2929

3030
protected override void SetupApplicationAndCommands()
3131
{
32-
Name = GlobalConstants.CreateName;
33-
Description = GlobalConstants.CreateDescription;
34-
35-
_appInsightsInstrumentationKey = Option("--appInsightsInstrumentationKey <appInsightsInstrumentationKey>", "AppInsights intrumentationkey", CommandOptionType.SingleValue);
36-
_appInsightsName = Option("--appInsightsName <appInsightsName>", "AppInsights Name", CommandOptionType.SingleValue);
37-
_namedValueKeys = Option("--namedValues <namedValues>", "Named Values", CommandOptionType.SingleValue);
38-
_apimNameValue = Option("--apimNameValue <apimNameValue>", "Apim Name Value", CommandOptionType.SingleValue);
39-
_configFile = Option("--configFile <configFile>", "Config YAML file location", CommandOptionType.SingleValue).IsRequired();
40-
_backendUrlConfigFile = Option("--backendurlconfigFile <backendurlconfigFile>", "backend url json file location", CommandOptionType.SingleValue);
41-
_preferredAPIsForDeployment = Option("--preferredAPIsForDeployment <preferredAPIsForDeployment>", "create ARM templates for the given APIs Name(comma separated) else leave this parameter blank then by default all api's will be considered", CommandOptionType.SingleValue);
32+
this.Name = GlobalConstants.CreateName;
33+
this.Description = GlobalConstants.CreateDescription;
34+
35+
this.appInsightsInstrumentationKey = this.Option("--appInsightsInstrumentationKey <appInsightsInstrumentationKey>", "AppInsights intrumentationkey", CommandOptionType.SingleValue);
36+
this.appInsightsName = this.Option("--appInsightsName <appInsightsName>", "AppInsights Name", CommandOptionType.SingleValue);
37+
this.namedValueKeys = this.Option("--namedValues <namedValues>", "Named Values", CommandOptionType.SingleValue);
38+
this.apimNameValue = this.Option("--apimNameValue <apimNameValue>", "Apim Name Value", CommandOptionType.SingleValue);
39+
this.configFile = this.Option("--configFile <configFile>", "Config YAML file location", CommandOptionType.SingleValue).IsRequired();
40+
this.backendUrlConfigFile = this.Option("--backendurlconfigFile <backendurlconfigFile>", "backend url json file location", CommandOptionType.SingleValue);
41+
this.preferredAPIsForDeployment = this.Option("--preferredAPIsForDeployment <preferredAPIsForDeployment>", "create ARM templates for the given APIs Name(comma separated) else leave this parameter blank then by default all api's will be considered", CommandOptionType.SingleValue);
4242
}
4343

4444
protected override async Task<int> ExecuteCommand()
@@ -50,35 +50,35 @@ protected override async Task<int> ExecuteCommand()
5050

5151
GlobalConstants.CommandStartDateTime = DateTime.Now.ToString("MMyyyydd hh mm ss");
5252

53-
CreatorConfig creatorConfig = await fileReader.ConvertConfigYAMLToCreatorConfigAsync(_configFile.Value());
53+
CreatorConfig creatorConfig = await fileReader.ConvertConfigYAMLToCreatorConfigAsync(this.configFile.Value());
5454

55-
if (_apimNameValue != null && !string.IsNullOrEmpty(_apimNameValue.Value()))
55+
if (this.apimNameValue != null && !string.IsNullOrEmpty(this.apimNameValue.Value()))
5656
{
57-
creatorConfig.apimServiceName = _apimNameValue.Value();
57+
creatorConfig.apimServiceName = this.apimNameValue.Value();
5858
}
5959

6060
AppInsightsUpdater appInsightsUpdater = new AppInsightsUpdater();
61-
appInsightsUpdater.UpdateAppInsightNameAndInstrumentationKey(creatorConfig, _appInsightsInstrumentationKey, _appInsightsName);
61+
appInsightsUpdater.UpdateAppInsightNameAndInstrumentationKey(creatorConfig, this.appInsightsInstrumentationKey, this.appInsightsName);
6262

6363
// Overwrite named values from build pipeline
6464
NamedValuesUpdater namedValuesUpdater = new NamedValuesUpdater();
65-
namedValuesUpdater.UpdateNamedValueInstances(creatorConfig, _namedValueKeys);
65+
namedValuesUpdater.UpdateNamedValueInstances(creatorConfig, this.namedValueKeys);
6666

6767
// validate creator config
6868
CreatorConfigurationValidator creatorConfigurationValidator = new CreatorConfigurationValidator(this);
6969

7070
//if preferredAPIsForDeployment passed as parameter
71-
if (_preferredAPIsForDeployment != null && !string.IsNullOrEmpty(_preferredAPIsForDeployment.Value()))
71+
if (this.preferredAPIsForDeployment != null && !string.IsNullOrEmpty(this.preferredAPIsForDeployment.Value()))
7272
{
7373
considerAllApiForDeployments = false;
74-
preferredApis = _preferredAPIsForDeployment.Value().Split(",");
74+
preferredApis = this.preferredAPIsForDeployment.Value().Split(",");
7575
}
7676

7777
//if backendurlfile passed as parameter
78-
if (_backendUrlConfigFile != null && !string.IsNullOrEmpty(_backendUrlConfigFile.Value()))
78+
if (this.backendUrlConfigFile != null && !string.IsNullOrEmpty(this.backendUrlConfigFile.Value()))
7979
{
8080
CreatorApiBackendUrlUpdater creatorApiBackendUrlUpdater = new CreatorApiBackendUrlUpdater();
81-
creatorConfig = creatorApiBackendUrlUpdater.UpdateBackendServiceUrl(_backendUrlConfigFile.Value(), creatorConfig);
81+
creatorConfig = creatorApiBackendUrlUpdater.UpdateBackendServiceUrl(this.backendUrlConfigFile.Value(), creatorConfig);
8282
}
8383

8484
bool isValidCreatorConfig = creatorConfigurationValidator.ValidateCreatorConfig(creatorConfig);
@@ -161,7 +161,7 @@ protected override async Task<int> ExecuteCommand()
161161
apiInformation.Add(new LinkedMasterTemplateAPIInformation()
162162
{
163163
name = api.name,
164-
isSplit = apiTemplateCreator.isSplitAPI(api),
164+
isSplit = apiTemplateCreator.IsSplitAPI(api),
165165
dependsOnGlobalServicePolicies = creatorConfig.policy != null,
166166
dependsOnVersionSets = api.apiVersionSetId != null,
167167
dependsOnVersion = masterTemplateCreator.GetDependsOnPreviousApiVersion(api, apiVersions),
@@ -194,7 +194,7 @@ protected override async Task<int> ExecuteCommand()
194194
APITemplateResource apiResource = apiTemplate.resources.FirstOrDefault(resource => resource.type == ResourceTypeConstants.API) as APITemplateResource;
195195
APIConfig providedAPIConfiguration = creatorConfig.apis.FirstOrDefault(api => string.Compare(apiResource.name, APITemplateCreator.MakeResourceName(api), true) == 0);
196196
// if the api version is not null the api is split into multiple templates. If the template is split and the content value has been set, then the template is for a subsequent api
197-
string apiFileName = FileNameGenerator.GenerateCreatorAPIFileName(providedAPIConfiguration.name, apiTemplateCreator.isSplitAPI(providedAPIConfiguration), apiResource.properties.value != null);
197+
string apiFileName = FileNameGenerator.GenerateCreatorAPIFileName(providedAPIConfiguration.name, apiTemplateCreator.IsSplitAPI(providedAPIConfiguration), apiResource.properties.value != null);
198198
FileWriter.WriteJSONToFile(apiTemplate, string.Concat(creatorConfig.outputLocation, apiFileName));
199199
}
200200
if (globalServicePolicyTemplate != null)

src/ArmTemplates/Commands/Applications/ExtractApplicationCommand.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,36 @@ namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Commands.Applica
1414
{
1515
public class ExtractApplicationCommand : CommandLineApplicationBase
1616
{
17-
private ExtractorConfig _extractorConfig;
17+
ExtractorConfig extractorConfig;
1818

1919
public ExtractApplicationCommand() : base()
2020
{
2121
}
2222

2323
protected override void SetupApplicationAndCommands()
2424
{
25-
Name = GlobalConstants.ExtractName;
26-
Description = GlobalConstants.ExtractDescription;
25+
this.Name = GlobalConstants.ExtractName;
26+
this.Description = GlobalConstants.ExtractDescription;
2727

28-
var extractorConfigFilePathOption = Option("--extractorConfig <extractorConfig>", "Config file of the extractor", CommandOptionType.SingleValue);
29-
AddExtractorConfigPropertiesToCommandLineOptions();
28+
var extractorConfigFilePathOption = this.Option("--extractorConfig <extractorConfig>", "Config file of the extractor", CommandOptionType.SingleValue);
29+
this.AddExtractorConfigPropertiesToCommandLineOptions();
3030

3131
if (extractorConfigFilePathOption.HasValue())
3232
{
3333
var fileReader = new FileReader();
34-
_extractorConfig = fileReader.ConvertConfigJsonToExtractorConfig(extractorConfigFilePathOption.Value());
34+
this.extractorConfig = fileReader.ConvertConfigJsonToExtractorConfig(extractorConfigFilePathOption.Value());
3535
}
3636

37-
UpdateExtractorConfigFromAdditionalArguments();
37+
this.UpdateExtractorConfigFromAdditionalArguments();
3838
}
3939

4040
protected override async Task<int> ExecuteCommand()
4141
{
4242
try
4343
{
44-
_extractorConfig.Validate();
44+
this.extractorConfig.Validate();
4545

46-
var extractorExecutor = new ExtractorExecutor(_extractorConfig);
46+
var extractorExecutor = new ExtractorExecutor(this.extractorConfig);
4747
await extractorExecutor.ExecuteGenerationBasedOnExtractorConfiguration();
4848

4949
Logger.LogInformation("Templates written to output location");
@@ -61,22 +61,22 @@ protected override async Task<int> ExecuteCommand()
6161
}
6262
}
6363

64-
private void AddExtractorConfigPropertiesToCommandLineOptions()
64+
void AddExtractorConfigPropertiesToCommandLineOptions()
6565
{
6666
foreach (var propertyInfo in typeof(ExtractorConfig).GetProperties())
6767
{
6868
var description = Attribute.IsDefined(propertyInfo, typeof(DescriptionAttribute)) ? (Attribute.GetCustomAttribute(propertyInfo, typeof(DescriptionAttribute)) as DescriptionAttribute).Description : string.Empty;
6969

70-
Option($"--{propertyInfo.Name} <{propertyInfo.Name}>", description, CommandOptionType.SingleValue);
70+
this.Option($"--{propertyInfo.Name} <{propertyInfo.Name}>", description, CommandOptionType.SingleValue);
7171
}
7272
}
7373

74-
private void UpdateExtractorConfigFromAdditionalArguments()
74+
void UpdateExtractorConfigFromAdditionalArguments()
7575
{
7676
var extractorConfigType = typeof(ExtractorConfig);
77-
foreach (var option in Options.Where(o => o.HasValue()))
77+
foreach (var option in this.Options.Where(o => o.HasValue()))
7878
{
79-
extractorConfigType.GetProperty(option.LongName)?.SetValue(_extractorConfig, option.Value());
79+
extractorConfigType.GetProperty(option.LongName)?.SetValue(this.extractorConfig, option.Value());
8080
}
8181
}
8282
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Commands.Executors
22
{
3-
internal class CreatorExecutor
3+
class CreatorExecutor
44
{
5+
// TODO refactor creatorApplicationCommand like ExtractorExecutor
6+
// Issue: https://github.com/Azure/azure-api-management-devops-resource-kit/issues/623
57
}
68
}

0 commit comments

Comments
 (0)