Skip to content

Commit 916d39e

Browse files
Update to .NET 10 (#261)
* Update to .NET 10, fix Spectre.Console.Cli breaking changes and fix all warnings * Improve null-safety across buffer commands and tasks Removed `#nullable enable annotations` directives and updated properties and parameters to be nullable where appropriate (e.g., `FilePath?`, `Uri?`, `string?`) in buffer commands (`BlueskyBufferCommand`, `FacebookBufferCommand`, `LinkedInBufferCommand`, `MastodonBufferCommand`, `TwitterBufferCommand`) and the `IContentTasks` interface. Refactored `ContentTasks` methods (`BufferContentItemsAsync`, `LoadContentItemsAsync`, `ShuffleBufferQueueAsync`) to handle nullable values using null-safe operations, such as the null-coalescing operator. These changes enhance null-safety, reduce the risk of null reference exceptions, and align with modern C# nullable reference type practices. * Bump major version
1 parent e26378e commit 916d39e

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

+480
-425
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
needs: prepareConfig
5656
uses: endjin/Endjin.RecommendedPractices.GitHubActions/.github/workflows/scripted-build-pipeline.yml@main
5757
with:
58-
netSdkVersion: '8.x'
58+
netSdkVersion: '10.x'
5959
# workflow_dispatch inputs are always strings, the type property is just for the UI
6060
forcePublish: ${{ github.event.inputs.forcePublish == 'true' }}
6161
skipCleanup: ${{ github.event.inputs.skipCleanup == 'true' }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,5 @@ FodyWeavers.xsd
403403
*.sbom*
404404
_codeCoverage/
405405
_packages/
406+
/.claude
407+
/.devcontainer

GitVersion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ branches:
2020
- feature
2121
- support
2222
- hotfix
23-
next-version: "1.0"
23+
next-version: "2.0"
2424

Solutions/Stacker.Cli.Specs/Features/WordPressExportToTwitter.feature.cs

Lines changed: 42 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Solutions/Stacker.Cli.Specs/Stacker.Cli.Specs.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<IsPackable>false</IsPackable>
77
<IsTestProject>true</IsTestProject>
@@ -13,7 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Corvus.Testing.ReqnRoll.NUnit" Version="4.0.3" />
16+
<PackageReference Include="Corvus.Testing.ReqnRoll.NUnit" Version="4.0.5" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

Solutions/Stacker.Cli/BufferClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public async Task UploadAsync(IEnumerable<string> content, string profileId, boo
6262
if (!response.IsSuccessStatusCode)
6363
{
6464
string errorContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
65-
BufferError error = JsonSerializer.Deserialize<BufferError>(errorContent);
65+
BufferError? error = JsonSerializer.Deserialize<BufferError>(errorContent);
6666

67-
AnsiConsole.MarkupLineInterpolated($"[red]Buffering Failed:[/] {error.Message}");
67+
AnsiConsole.MarkupLineInterpolated($"[red]Buffering Failed:[/] {error?.Message ?? "Unknown error"}");
6868
AnsiConsole.WriteLine();
6969
}
7070
}
@@ -100,13 +100,13 @@ public async Task<BufferShuffleResponse> ShuffleAsync(string profileId, int? cou
100100

101101
if (!response.IsSuccessStatusCode)
102102
{
103-
BufferError error = JsonSerializer.Deserialize<BufferError>(content);
104-
AnsiConsole.MarkupLineInterpolated($"[red]Shuffling Failed:[/] {error?.Message}");
103+
BufferError? error = JsonSerializer.Deserialize<BufferError>(content);
104+
AnsiConsole.MarkupLineInterpolated($"[red]Shuffling Failed:[/] {error?.Message ?? "Unknown error"}");
105105
AnsiConsole.WriteLine();
106106
return new BufferShuffleResponse { Success = false };
107107
}
108108

109-
BufferShuffleResponse result = JsonSerializer.Deserialize<BufferShuffleResponse>(content);
109+
BufferShuffleResponse? result = JsonSerializer.Deserialize<BufferShuffleResponse>(content);
110110
AnsiConsole.MarkupLine("[chartreuse3_1]Shuffling completed successfully[/]");
111111

112112
return result ?? new BufferShuffleResponse { Success = false };

Solutions/Stacker.Cli/BufferError.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public class BufferError
1313
public bool Success { get; set; }
1414

1515
[JsonPropertyName("message")]
16-
public string Message { get; set; }
16+
public string Message { get; set; } = string.Empty;
1717

1818
[JsonPropertyName("code")]
1919
public int Code { get; set; }
2020

2121
[JsonPropertyName("errored_profiles")]
22-
public IEnumerable<Profiles> ErroredProfiles { get; set; }
22+
public IEnumerable<Profiles> ErroredProfiles { get; set; } = [];
2323
}

Solutions/Stacker.Cli/Commands/BlueskyBufferCommand.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using System;
66
using System.ComponentModel;
77
using System.Diagnostics.CodeAnalysis;
8+
using System.Threading;
89
using System.Threading.Tasks;
9-
1010
using Spectre.Console.Cli;
1111
using Spectre.IO;
1212

@@ -27,7 +27,7 @@ public BlueskyBufferCommand(IContentTasks contentTasks)
2727
}
2828

2929
/// <inheritdoc/>
30-
public override async Task<int> ExecuteAsync([NotNull] CommandContext context, [NotNull] Settings settings)
30+
public override async Task<int> ExecuteAsync([NotNull] CommandContext context, [NotNull] Settings settings, CancellationToken cancellationToken)
3131
{
3232
await this.contentTasks.BufferContentItemsAsync<BlueskyFormatter>(
3333
settings.ContentFilePath,
@@ -50,23 +50,21 @@ await this.contentTasks.BufferContentItemsAsync<BlueskyFormatter>(
5050
/// </summary>
5151
public class Settings : CommandSettings
5252
{
53-
#nullable disable annotations
54-
5553
[CommandOption("-c|--content-file-path")]
5654
[Description("Content file path.")]
57-
public FilePath ContentFilePath { get; init; }
55+
public FilePath? ContentFilePath { get; init; }
5856

5957
[CommandOption("-h|--content-http-uri")]
6058
[Description("Content http uri.")]
61-
public Uri ContentUri { get; init; }
59+
public Uri? ContentUri { get; init; }
6260

6361
[CommandOption("-n|--profile-name")]
6462
[Description("Twitter profile to Buffer.")]
65-
public string ProfileName { get; init; }
63+
public string? ProfileName { get; init; }
6664

6765
[CommandOption("-g|--filter-by-tag")]
6866
[Description("Tag to filter the content items by.")]
69-
public string FilterByTag { get; init; }
67+
public string? FilterByTag { get; init; }
7068

7169
[CommandOption("-i|--item-count")]
7270
[Description("Number of content items to buffer. If omitted all content is buffered.")]

Solutions/Stacker.Cli/Commands/BufferShuffleCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System.ComponentModel;
66
using System.Diagnostics.CodeAnalysis;
7+
using System.Threading;
78
using System.Threading.Tasks;
89

910
using Spectre.Console.Cli;
@@ -24,7 +25,7 @@ public BufferShuffleCommand(IContentTasks contentTasks, string profile)
2425
}
2526

2627
/// <inheritdoc/>
27-
public override async Task<int> ExecuteAsync([NotNull] CommandContext context, [NotNull] Settings settings)
28+
public override async Task<int> ExecuteAsync([NotNull] CommandContext context, [NotNull] Settings settings, CancellationToken cancellationToken)
2829
{
2930
BufferShuffleResponse result = await this.contentTasks.ShuffleBufferQueueAsync(
3031
this.profilePrefix,
@@ -41,7 +42,7 @@ public class Settings : CommandSettings
4142
{
4243
[CommandOption("-n|--profile-name")]
4344
[Description("Buffer profile name to shuffle.")]
44-
public string ProfileName { get; init; }
45+
public required string ProfileName { get; init; }
4546

4647
[CommandOption("-c|--count")]
4748
[Description("Number of updates to shuffle. If omitted, all scheduled updates are shuffled.")]

Solutions/Stacker.Cli/Commands/EnvironmentInitCommand.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Copyright (c) Endjin Limited. All rights reserved.
33
// </copyright>
44

5-
#nullable enable annotations
6-
75
using System.Collections.Generic;
6+
using System.Diagnostics.CodeAnalysis;
7+
using System.Threading;
88

99
using Spectre.Console;
1010
using Spectre.Console.Cli;
@@ -25,7 +25,7 @@ public EnvironmentInitCommand(IAppEnvironment appEnvironment, IStackerSettingsMa
2525
this.settingsManager = settingsManager;
2626
}
2727

28-
public override int Execute(CommandContext context)
28+
public override int Execute([NotNull] CommandContext context, CancellationToken cancellationToken)
2929
{
3030
this.appEnvironment.Initialize();
3131
this.settingsManager.SaveSettings(
@@ -44,8 +44,10 @@ public override int Execute(CommandContext context)
4444
{
4545
Email = string.Empty,
4646
IsActive = true,
47+
Twitter = string.Empty,
4748
}
4849
],
50+
WordPressToMarkdown = new WordPressToMarkdown(),
4951
},
5052
nameof(StackerSettings));
5153

0 commit comments

Comments
 (0)