Skip to content

Commit 7036b17

Browse files
authored
Use dotnet format (#66)
Covers the formatting part of #13
1 parent 05711e4 commit 7036b17

Some content is hidden

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

42 files changed

+186
-138
lines changed

.github/workflows/pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
uses: actions/setup-dotnet@v1
3030
with:
3131
dotnet-version: '6.0.x'
32+
- name: Format Pulumi SDK
33+
run: dotnet run format-sdk verify
3234
- name: Build Pulumi SDK
3335
run: dotnet run build-sdk
3436
- name: Test Pulumi SDK

build/Program.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ let restoreSdk() =
5252
if Shell.Exec("dotnet", "restore --no-cache", sdk) <> 0
5353
then failwith "restore failed"
5454

55+
/// Runs `dotnet format` against the solution file
56+
let formatSdk verify =
57+
printfn "Formatting Pulumi SDK packages"
58+
let args = "format" + if verify then " --verify-no-changes" else ""
59+
if Shell.Exec("dotnet", args, sdk) <> 0
60+
then failwith "format failed"
61+
5562
/// Returns an array of names of go tests inside ./integration_tests
5663
/// You can use this to see which tests are available,
5764
/// then run individual tests using `dotnet run integration test <testName>`
@@ -178,6 +185,8 @@ let main(args: string[]) : int =
178185
match args with
179186
| [| "clean-sdk" |] -> cleanSdk()
180187
| [| "build-sdk" |] -> buildSdk()
188+
| [| "format-sdk" |] -> formatSdk false
189+
| [| "format-sdk"; "verify" |] -> formatSdk true
181190
| [| "build-language-plugin" |] -> buildLanguagePlugin()
182191
| [| "test-language-plugin" |] -> testLanguagePlugin()
183192
| [| "test-sdk" |] -> testPulumiSdk()

sdk/Pulumi.Automation.Tests/CommandExceptionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ await Assert.ThrowsAsync<StackAlreadyExistsException>(
6565
[Fact]
6666
public async Task ConcurrentUpdateExceptionIsThrown()
6767
{
68-
68+
6969
var projectSettings = new ProjectSettings("command_exception_test", ProjectRuntimeName.NodeJS);
7070
using var workspace = await LocalWorkspace.CreateAsync(new LocalWorkspaceOptions
7171
{

sdk/Pulumi.Automation.Tests/LocalPulumiCmdTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public async Task CheckVersionCommand()
3737

3838
Assert.Matches(@"^v?\d+\.\d+\.\d+", result.StandardOutput);
3939
// stderr must strictly begin with the version warning message or be an empty string:
40-
if (result.StandardError.Length > 0) {
40+
if (result.StandardError.Length > 0)
41+
{
4142
Assert.StartsWith("warning: A new version of Pulumi", result.StandardError);
4243
}
4344

sdk/Pulumi.Automation.Tests/LocalWorkspaceTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ static async Task<T> RunCommand<T, TOptions>(Func<TOptions, CancellationToken, T
817817
}
818818

819819
// TODO[pulumi/pulumi#7127]: Re-enable the warning.
820-
[Fact(Skip="Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127")]
820+
[Fact(Skip = "Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127")]
821821
public async Task ConfigSecretWarnings()
822822
{
823823
var program = PulumiFn.Create(() =>
@@ -1269,7 +1269,7 @@ await Assert.ThrowsAsync<FileNotFoundException>(
12691269
}
12701270

12711271
// TODO[pulumi/pulumi#8228]: fix flakiness
1272-
[Fact(Skip="flaky")]
1272+
[Fact(Skip = "flaky")]
12731273
public async Task InlineProgramExceptionPropagatesToCallerWithServiceProvider()
12741274
{
12751275
await using var provider = new ServiceCollection()
@@ -2033,14 +2033,16 @@ public async Task TestUpdatePlans()
20332033
{
20342034
var planFile = System.IO.Path.GetTempFileName();
20352035

2036-
await stack.PreviewAsync(new PreviewOptions {
2036+
await stack.PreviewAsync(new PreviewOptions
2037+
{
20372038
Plan = planFile,
20382039
});
20392040

20402041
var planFileStream = System.IO.File.OpenRead(planFile);
20412042
Assert.NotEqual(0, planFileStream.Length);
20422043

2043-
await stack.UpAsync(new UpOptions {
2044+
await stack.UpAsync(new UpOptions
2045+
{
20442046
Plan = planFile,
20452047
});
20462048

sdk/Pulumi.Automation.Tests/RemoteWorkspaceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public Task CreateOrSelectStackLifecycle()
148148

149149
private static async Task TestStackLifeCycle(Func<RemoteGitProgramArgs, Task<RemoteWorkspaceStack>> factory)
150150
{
151-
var stackName = FullyQualifiedStackName(GetTestOrg(), "go_remote_proj", RandomStackName());
151+
var stackName = FullyQualifiedStackName(GetTestOrg(), "go_remote_proj", RandomStackName());
152152
using var stack = await factory(new RemoteGitProgramArgs(stackName, _testRepo)
153153
{
154154
Branch = "refs/heads/master",

sdk/Pulumi.Automation/Commands/LocalPulumiCmd.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ public async Task<CommandResult> RunAsync(
3535
try
3636
{
3737
return await RunAsyncInner(args, workingDir, additionalEnv, onStandardOutput, onStandardError, eventLogFile, cancellationToken).ConfigureAwait(false);
38-
} finally {
38+
}
39+
finally
40+
{
3941
await eventLogWatcher.Stop().ConfigureAwait(false);
4042
}
4143
}

sdk/Pulumi.Automation/Events/CancelEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ namespace Pulumi.Automation.Events
1010
/// </summary>
1111
public class CancelEvent
1212
{
13-
internal CancelEvent() {}
13+
internal CancelEvent() { }
1414
}
1515
}

sdk/Pulumi.Automation/PreviewOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public sealed class PreviewOptions : UpdateOptions
2323
/// <summary>
2424
/// Plan specifies the path where the update plan should be saved.
2525
/// </summary>
26-
public string? Plan {get; set; }
26+
public string? Plan { get; set; }
2727

2828
/// <summary>
2929
/// A custom logger instance that will be used for the action. Note that it will only be used

sdk/Pulumi.Automation/Serialization/IStringToEnumConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Pulumi.Automation.Serialization
66
{
77
internal interface IStringToEnumConverter<out TEnum>
8-
where TEnum: struct, Enum
8+
where TEnum : struct, Enum
99
{
1010
TEnum Convert(string input);
1111
}

sdk/Pulumi.Automation/Serialization/Json/StackSettingsConfigValueJsonConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public override StackSettingsConfigValue Read(ref Utf8JsonReader reader, Type ty
2424
// otherwise, serialize the whole object as JSON into the stack settings value
2525
if (element.ValueKind == JsonValueKind.Object)
2626
{
27-
foreach(var property in element.EnumerateObject())
27+
foreach (var property in element.EnumerateObject())
2828
{
2929
if (string.Equals("Secure", property.Name, StringComparison.OrdinalIgnoreCase))
3030
{

sdk/Pulumi.Automation/Serialization/Yaml/StackSettingsConfigValueYamlConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public object ReadYaml(IParser parser, Type type)
4141
if (!parser.TryConsume<Scalar>(out var securePropertyValue))
4242
throw new YamlException($"Unable to deserialize [{type.FullName}] as a secure string. Expecting a string secret.");
4343

44-
// needs to be 1 mapping end and then return
44+
// needs to be 1 mapping end and then return
4545
parser.Require<MappingEnd>();
4646
parser.MoveNext();
4747
return new StackSettingsConfigValue(securePropertyValue.Value, true);

sdk/Pulumi.Automation/StackSettings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class StackSettings
1111
/// <summary>
1212
/// This stack's secrets provider.
1313
/// </summary>
14-
[YamlMember(Alias="secretsprovider")]
14+
[YamlMember(Alias = "secretsprovider")]
1515
[JsonPropertyName("secretsprovider")]
1616

1717
public string? SecretsProvider { get; set; }
@@ -20,7 +20,7 @@ public class StackSettings
2020
/// This is the KMS-encrypted ciphertext for the data key used for secrets
2121
/// encryption. Only used for cloud-based secrets providers.
2222
/// </summary>
23-
[YamlMember(Alias="encryptedkey")]
23+
[YamlMember(Alias = "encryptedkey")]
2424
[JsonPropertyName("encryptedkey")]
2525

2626
public string? EncryptedKey { get; set; }
@@ -29,15 +29,15 @@ public class StackSettings
2929
/// This is this stack's base64 encoded encryption salt. Only used for
3030
/// passphrase-based secrets providers.
3131
/// </summary>
32-
[YamlMember(Alias="encryptionsalt")]
32+
[YamlMember(Alias = "encryptionsalt")]
3333
[JsonPropertyName("encryptionsalt")]
3434

3535
public string? EncryptionSalt { get; set; }
3636

3737
/// <summary>
3838
/// This is an optional configuration bag.
3939
/// </summary>
40-
40+
4141
public IDictionary<string, StackSettingsConfigValue>? Config { get; set; }
4242
}
4343
}

sdk/Pulumi.Automation/UpOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public sealed class UpOptions : UpdateOptions
2323
/// <summary>
2424
/// Plan specifies the path to an update plan to use for the update.
2525
/// </summary>
26-
public string? Plan {get; set; }
26+
public string? Plan { get; set; }
2727

2828
/// <summary>
2929
/// Show config secrets when they appear.

sdk/Pulumi.Tests/Core/InputTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Task MergeInputMaps()
3232
var data = await result.ToOutput().DataTask.ConfigureAwait(false);
3333
Assert.True(data.IsKnown);
3434
Assert.Equal(4, data.Value.Count);
35-
for (var i = 1; i <=4; i++)
35+
for (var i = 1; i <= 4; i++)
3636
Assert.True(data.Value.Contains($"K{i}", $"V{i}"));
3737

3838
// Check that the input maps haven't changed
@@ -126,19 +126,19 @@ public Task InputListUnionInitializer()
126126
public Task InputUnionInitializer()
127127
=> RunInPreview(async () =>
128128
{
129-
var sample = new SampleArgs{ Union = "testValue" };
129+
var sample = new SampleArgs { Union = "testValue" };
130130
var data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
131131
Assert.Equal("testValue", data.Value);
132132

133-
sample = new SampleArgs{ Union = 123 };
133+
sample = new SampleArgs { Union = 123 };
134134
data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
135135
Assert.Equal(123, data.Value);
136136

137-
sample = new SampleArgs{ Union = Union<string, int>.FromT0("left") };
137+
sample = new SampleArgs { Union = Union<string, int>.FromT0("left") };
138138
data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
139139
Assert.Equal("left", data.Value);
140140

141-
sample = new SampleArgs{ Union = Union<string, int>.FromT1(456) };
141+
sample = new SampleArgs { Union = Union<string, int>.FromT1(456) };
142142
data = await sample.Union.ToOutput().DataTask.ConfigureAwait(false);
143143
Assert.Equal(456, data.Value);
144144
});

sdk/Pulumi.Tests/Core/OutputTests.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
namespace Pulumi.Tests.Core
1212
{
1313
// Simple struct used for JSON tests
14-
public struct TestStructure {
15-
public int X { get; set;}
14+
public struct TestStructure
15+
{
16+
public int X { get; set; }
1617

1718
private int y;
1819

19-
public string Z => (y+1).ToString();
20+
public string Z => (y + 1).ToString();
2021

21-
public TestStructure(int x, int y) {
22+
public TestStructure(int x, int y)
23+
{
2224
X = x;
2325
this.y = y;
2426
}
@@ -285,7 +287,7 @@ public Task AllEnumerableOutputs()
285287
{
286288
var o1 = CreateOutput(1, isKnown: true);
287289
var o2 = CreateOutput(2, isKnown: true);
288-
var outputs = new[] {o1, o2}.AsEnumerable();
290+
var outputs = new[] { o1, o2 }.AsEnumerable();
289291
var o3 = Output.All(outputs);
290292
var data = await o3.DataTask.ConfigureAwait(false);
291293
Assert.Equal(new[] { 1, 2 }, data.Value);
@@ -308,7 +310,7 @@ public Task AllEnumerableInputs()
308310
{
309311
var i1 = (Input<int>)CreateOutput(1, isKnown: true);
310312
var i2 = (Input<int>)CreateOutput(2, isKnown: true);
311-
var inputs = new[] {i1, i2}.AsEnumerable();
313+
var inputs = new[] { i1, i2 }.AsEnumerable();
312314
var o = Output.All(inputs);
313315
var data = await o.DataTask.ConfigureAwait(false);
314316
Assert.Equal(new[] { 1, 2 }, data.Value);
@@ -642,7 +644,7 @@ public Task CreateSecretSetsSecret()
642644
public Task JsonSerializeBasic()
643645
=> RunInNormal(async () =>
644646
{
645-
var o1 = CreateOutput(new int[]{ 0, 1} , true);
647+
var o1 = CreateOutput(new int[] { 0, 1 }, true);
646648
var o2 = Output.JsonSerialize(o1);
647649
var data = await o2.DataTask.ConfigureAwait(false);
648650
Assert.True(data.IsKnown);
@@ -722,7 +724,7 @@ public Task JsonSerializeWithOptions()
722724
});
723725

724726
[Fact]
725-
public async Task JsonSerializeNestedDependencies()
727+
public async Task JsonSerializeNestedDependencies()
726728
{
727729
// We need a custom mock setup for this because new CustomResource will call into the
728730
// deployment to try and register.
@@ -764,7 +766,7 @@ public Task JsonDeserializeBasic()
764766
var data = await o2.DataTask.ConfigureAwait(false);
765767
Assert.True(data.IsKnown);
766768
Assert.False(data.IsSecret);
767-
Assert.Equal(new int[] {0, 1}, data.Value);
769+
Assert.Equal(new int[] { 0, 1 }, data.Value);
768770
});
769771

770772
[Fact]
@@ -828,7 +830,7 @@ public async Task JsonDeserializeNestedDependencies()
828830
var resource = new CustomResource("type", "name", null);
829831

830832
var o1 = CreateOutput(new Resource[] { resource }, "[0,1]", true, true);
831-
var o2 = Output.JsonDeserialize<Output<int>[]>(o1);
833+
var o2 = Output.JsonDeserialize<Output<int>[]>(o1);
832834
var data = await o2.DataTask.ConfigureAwait(false);
833835
Assert.True(data.IsKnown);
834836
Assert.True(data.IsSecret);

sdk/Pulumi.Tests/Deployment/DeploymentResourceDependencyGatheringTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public DeploysResourcesWithUnknownDependsOnStack()
3333
{
3434
new MyCustomResource("r1", null, new CustomResourceOptions()
3535
{
36-
DependsOn = Output<Resource[]>.CreateUnknown(new Resource[]{}),
36+
DependsOn = Output<Resource[]>.CreateUnknown(new Resource[] { }),
3737
});
3838
}
3939
}

sdk/Pulumi.Tests/Deployment/DeploymentRunnerTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public IDisposable BeginScope<TState>(TState state)
117117
Write($"BeginScope state={state}");
118118
return new Scope()
119119
{
120-
Close = () => {
120+
Close = () =>
121+
{
121122
Write($"EndScope state={state}");
122123
}
123124
};
@@ -138,7 +139,7 @@ private void Write(string message)
138139

139140
class Scope : IDisposable
140141
{
141-
public Action Close { get; set; } = () => {};
142+
public Action Close { get; set; } = () => { };
142143

143144
public void Dispose()
144145
{

0 commit comments

Comments
 (0)