Skip to content

Commit

Permalink
Basic linting and formatting updates (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernieWhite authored Oct 12, 2024
1 parent 3439959 commit ad13c4b
Show file tree
Hide file tree
Showing 73 changed files with 3,404 additions and 3,477 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ indent_size = 2
[*.cs]

# Code style defaults
csharp_using_directive_placement = outside_namespace:suggestion
csharp_using_directive_placement = outside_namespace:error
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_preferred_modifier_order.severity = suggestion
dotnet_sort_system_directives_first = true
dotnet_sort_system_directives_first = true:error
dotnet_style_readonly_field = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
csharp_style_namespace_declarations = file_scoped:suggestion
dotnet_diagnostic.IDE0005.severity = error

# License header
file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.
dotnet_diagnostic.IDE0073.severity = error

# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
Expand Down
137 changes: 68 additions & 69 deletions src/PSRule.Rules.Azure.Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#if BENCHMARK
Expand All @@ -15,101 +15,100 @@
using System.Diagnostics;
using Microsoft.Extensions.CommandLineUtils;

namespace PSRule.Rules.Azure.Benchmark
namespace PSRule.Rules.Azure.Benchmark;

internal static class Program
{
internal static class Program
private static void Main(string[] args)
{
private static void Main(string[] args)
var app = new CommandLineApplication
{
var app = new CommandLineApplication
{
Name = "PSRule for Azure Benchmark",
Description = "A runner for testing PSRule performance"
};
Name = "PSRule for Azure Benchmark",
Description = "A runner for testing PSRule performance"
};

#if !BENCHMARK
// Do profiling
DebugProfile(app);
app.Execute(args);
// Do profiling
DebugProfile(app);
app.Execute(args);
#endif

#if BENCHMARK
RunProfile(app);
app.Execute(args);
RunProfile(app);
app.Execute(args);
#endif
}
}

#if BENCHMARK

private static void RunProfile(CommandLineApplication app)
private static void RunProfile(CommandLineApplication app)
{
var config = ManualConfig.CreateEmpty()
.AddLogger(ConsoleLogger.Default)
.AddColumnProvider(DefaultColumnProviders.Instance)
.AddAnalyser(EnvironmentAnalyser.Default)
.AddAnalyser(OutliersAnalyser.Default)
.AddAnalyser(MinIterationTimeAnalyser.Default)
.AddAnalyser(MultimodalDistributionAnalyzer.Default)
.AddAnalyser(RuntimeErrorAnalyser.Default)
.AddAnalyser(ZeroMeasurementAnalyser.Default);

app.Command("benchmark", cmd =>
{
var config = ManualConfig.CreateEmpty()
.AddLogger(ConsoleLogger.Default)
.AddColumnProvider(DefaultColumnProviders.Instance)
.AddAnalyser(EnvironmentAnalyser.Default)
.AddAnalyser(OutliersAnalyser.Default)
.AddAnalyser(MinIterationTimeAnalyser.Default)
.AddAnalyser(MultimodalDistributionAnalyzer.Default)
.AddAnalyser(RuntimeErrorAnalyser.Default)
.AddAnalyser(ZeroMeasurementAnalyser.Default);

app.Command("benchmark", cmd =>
var output = cmd.Option("-o | --output", "The path to store report output.", CommandOptionType.SingleValue);
cmd.OnExecute(() =>
{
var output = cmd.Option("-o | --output", "The path to store report output.", CommandOptionType.SingleValue);
cmd.OnExecute(() =>
if (output.HasValue())
{
if (output.HasValue())
{
config.WithArtifactsPath(output.Value());
}

// Do benchmarks
BenchmarkRunner.Run<PSRule>(config);
return 0;
});
cmd.HelpOption("-? | -h | --help");
config.WithArtifactsPath(output.Value());
}

// Do benchmarks
BenchmarkRunner.Run<PSRule>(config);
return 0;
});
app.HelpOption("-? | -h | --help");
}
cmd.HelpOption("-? | -h | --help");
});
app.HelpOption("-? | -h | --help");
}

#endif

private const int DebugIterations = 100;
private const int DebugIterations = 100;

private static void DebugProfile(CommandLineApplication app)
private static void DebugProfile(CommandLineApplication app)
{
app.Command("benchmark", cmd =>
{
app.Command("benchmark", cmd =>
cmd.OnExecute(() =>
{
cmd.OnExecute(() =>
{
Console.WriteLine("Press ENTER to start.");
Console.ReadLine();
RunDebug();
return 0;
});
Console.WriteLine("Press ENTER to start.");
Console.ReadLine();
RunDebug();
return 0;
});
}
});
}

private static void RunDebug()
{
var profile = new PSRule();
profile.Prepare();
private static void RunDebug()
{
var profile = new PSRule();
profile.Prepare();

ProfileBlock();
for (var i = 0; i < DebugIterations; i++)
profile.Template();
ProfileBlock();
for (var i = 0; i < DebugIterations; i++)
profile.Template();

for (var i = 0; i < DebugIterations; i++)
profile.PropertyCopyLoop();
for (var i = 0; i < DebugIterations; i++)
profile.PropertyCopyLoop();

for (var i = 0; i < DebugIterations; i++)
profile.UserDefinedFunctions();
}
for (var i = 0; i < DebugIterations; i++)
profile.UserDefinedFunctions();
}

[DebuggerStepThrough]
private static void ProfileBlock()
{
// Do nothing
}
[DebuggerStepThrough]
private static void ProfileBlock()
{
// Do nothing
}
}
29 changes: 0 additions & 29 deletions src/PSRule.Rules.Azure/Common/JsonCommentWriter.cs

This file was deleted.

84 changes: 0 additions & 84 deletions src/PSRule.Rules.Azure/Common/LocationHelper.cs

This file was deleted.

29 changes: 0 additions & 29 deletions src/PSRule.Rules.Azure/Common/OutputEncodingExtensions.cs

This file was deleted.

54 changes: 0 additions & 54 deletions src/PSRule.Rules.Azure/Common/PSObjectExtensions.cs

This file was deleted.

Loading

0 comments on commit ad13c4b

Please sign in to comment.