Skip to content

Commit

Permalink
Update Pulumi projects to net6.0
Browse files Browse the repository at this point in the history
.NET Core 3.1 is out of support on December 13th:
https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core

We've already stopped testing on .NET Core 3.1, and program gen has been targeting only 6.0 for a while now as well.

This updates the core porjects to only 6.0 as well.

We'll still want to do pulumi/pulumi#11543 in
pu/pu to update sdkgen.
  • Loading branch information
Frassle committed Dec 19, 2022
1 parent 83ac275 commit 5d5070f
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 35 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
- [auto] Adds SkipInstallDependencies option for Remote Workspaces
[#64](https://github.com/pulumi/pulumi-dotnet/pull/64)

- [sdk] Drop support for .NET Core 3.1.
[#10](https://github.com/pulumi/pulumi-dotnet/pull/10)

### Bug Fixes
1 change: 1 addition & 0 deletions sdk/Pulumi.Automation/Commands/LocalPulumiCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public EventLogFile(string command)
public void Dispose()
{
var dir = Path.GetDirectoryName(this.FilePath);
System.Diagnostics.Debug.Assert(dir != null, "FilePath had no directory name");
try
{
Directory.Delete(dir, recursive: true);
Expand Down
2 changes: 1 addition & 1 deletion sdk/Pulumi.Automation/Pulumi.Automation.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Pulumi</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public override StackSettingsConfigValue Read(ref Utf8JsonReader reader, Type ty
// check if plain string
if (element.ValueKind == JsonValueKind.String)
{
var value = element.GetString();
var value = element.GetString()!;
return new StackSettingsConfigValue(value, false);
}

Expand All @@ -33,8 +33,8 @@ public override StackSettingsConfigValue Read(ref Utf8JsonReader reader, Type ty
{
throw new JsonException($"Unable to deserialize [{typeToConvert.FullName}] as a secure string. Expecting a string secret.");
}
return new StackSettingsConfigValue(secureValue.GetString(), true);

return new StackSettingsConfigValue(secureValue.GetString()!, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class StringToEnumJsonConverter<TEnum, TConverter> : JsonConverter<TEnu

public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return _converter.Convert(reader.GetString());
return _converter.Convert(reader.GetString()!);
}

public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS
return datetime;
}

return reader.GetString();
return reader.GetString()!;
}

if (reader.TokenType == JsonTokenType.StartArray)
{
return JsonSerializer.Deserialize<object[]>(ref reader, options);
return JsonSerializer.Deserialize<object[]>(ref reader, options)!;
}

if (reader.TokenType == JsonTokenType.StartObject)
Expand All @@ -61,7 +61,7 @@ public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS
throw new JsonException("Unable to retrieve property name.");

reader.Read();
dictionary[propertyName] = JsonSerializer.Deserialize<object>(ref reader, options);
dictionary[propertyName] = JsonSerializer.Deserialize<object>(ref reader, options)!;

reader.Read();
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/Pulumi.Automation/Serialization/LocalSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public LocalSerializer()
}

public T DeserializeJson<T>(string content)
=> JsonSerializer.Deserialize<T>(content, this._jsonOptions);
=> JsonSerializer.Deserialize<T>(content, this._jsonOptions)!;

public T DeserializeYaml<T>(string content)
where T : class
Expand All @@ -45,7 +45,7 @@ public static JsonSerializerOptions BuildJsonSerializerOptions()
var options = new JsonSerializerOptions
{
AllowTrailingCommas = true,
IgnoreNullValues = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};

Expand Down
4 changes: 2 additions & 2 deletions sdk/Pulumi.Automation/WorkspaceStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void OnPreviewEvent(EngineEvent @event)
return ImmutableList<UpdateSummary>.Empty;

var jsonOptions = LocalSerializer.BuildJsonSerializerOptions();
var list = JsonSerializer.Deserialize<List<UpdateSummary>>(result.StandardOutput, jsonOptions);
var list = JsonSerializer.Deserialize<List<UpdateSummary>>(result.StandardOutput, jsonOptions)!;
return list.ToImmutableList();
}

Expand Down Expand Up @@ -705,7 +705,7 @@ private class InlineLanguageHost : IAsyncDisposable
try
{
var serverFeatures = this._host.Services.GetRequiredService<IServer>().Features;
var addresses = serverFeatures.Get<IServerAddressesFeature>().Addresses.ToList();
var addresses = serverFeatures.Get<IServerAddressesFeature>()!.Addresses.ToList();
Debug.Assert(addresses.Count == 1, "Server should only be listening on one address");
var uri = new Uri(addresses[0]);
this._portTcs.TrySetResult(uri.Port);
Expand Down
2 changes: 1 addition & 1 deletion sdk/Pulumi.FSharp/Pulumi.FSharp.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Pulumi</Authors>
<Company>Pulumi Corp.</Company>
Expand Down
23 changes: 3 additions & 20 deletions sdk/Pulumi/Core/Output.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,9 @@ async Task<OutputData<string>> GetData()
// This needs to handle nested potentially secret and unknown Output values, we do this by
// hooking options to handle any seen Output<T> values.

// TODO: This can be simplified in net6.0 to just new System.Text.Json.JsonSerializerOptions(options);
var internalOptions = new System.Text.Json.JsonSerializerOptions();
internalOptions.AllowTrailingCommas = options?.AllowTrailingCommas ?? internalOptions.AllowTrailingCommas;
if (options != null)
{
foreach(var converter in options.Converters)
{
internalOptions.Converters.Add(converter);
}
}
internalOptions.DefaultBufferSize = options?.DefaultBufferSize ?? internalOptions.DefaultBufferSize;
internalOptions.DictionaryKeyPolicy = options?.DictionaryKeyPolicy ?? internalOptions.DictionaryKeyPolicy;
internalOptions.Encoder = options?.Encoder ?? internalOptions.Encoder;
internalOptions.IgnoreNullValues = options?.IgnoreNullValues ?? internalOptions.IgnoreNullValues;
internalOptions.IgnoreReadOnlyProperties = options?.IgnoreReadOnlyProperties ?? internalOptions.IgnoreReadOnlyProperties;
internalOptions.MaxDepth = options?.MaxDepth ?? internalOptions.MaxDepth;
internalOptions.PropertyNameCaseInsensitive = options?.PropertyNameCaseInsensitive ?? internalOptions.PropertyNameCaseInsensitive;
internalOptions.PropertyNamingPolicy = options?.PropertyNamingPolicy ?? internalOptions.PropertyNamingPolicy;
internalOptions.ReadCommentHandling = options?.ReadCommentHandling ?? internalOptions.ReadCommentHandling;
internalOptions.WriteIndented = options?.WriteIndented ?? internalOptions.WriteIndented;
var internalOptions = options == null ?
new System.Text.Json.JsonSerializerOptions() :
new System.Text.Json.JsonSerializerOptions(options);

// Add the magic converter to allow us to do nested outputs
var outputConverter = new OutputJsonConverter();
Expand Down
2 changes: 1 addition & 1 deletion sdk/Pulumi/Deployment/Deployment_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static ImmutableHashSet<string> ParseConfigSecretKeys()
var envObject = JsonDocument.Parse(envConfigSecretKeys);
foreach (var element in envObject.RootElement.EnumerateArray())
{
parsedConfigSecretKeys.Add(element.GetString());
parsedConfigSecretKeys.Add(element.ToString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/Pulumi/Pulumi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Pulumi</Authors>
Expand Down

0 comments on commit 5d5070f

Please sign in to comment.