Skip to content

Commit

Permalink
Update to .NET 8 preview 7
Browse files Browse the repository at this point in the history
- Update to preview 7 of .NET 8.
- Fix new code analysis warnings.
- Use the new `UseArtifactsOutput` property for the output paths and adjust the build scripts accordingly.
- Remove Microsoft.SourceLink.GitHub as included in the .NET SDK now.
  • Loading branch information
martincostello committed Sep 10, 2023
1 parent 31d661f commit 9d1788d
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ jobs:
- name: Create Lambda ZIP file
if: runner.os == 'Linux'
run: |
cd "./artifacts/publish" || exit
cd "./artifacts/publish/LondonTravel.Skill/release_linux-arm64" || exit
if [ -f "./bootstrap" ]
then
chmod +x ./bootstrap
fi
zip -r "../${LAMBDA_FUNCTION}.zip" . || exit 1
zip -r "../../../${LAMBDA_FUNCTION}.zip" . || exit 1
- name: Publish deployment package
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
Expand Down
2 changes: 1 addition & 1 deletion .vsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.NetCore.Component.Runtime.7.0",
"Microsoft.NetCore.Component.Runtime.8.0",
"Microsoft.NetCore.Component.SDK",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices"
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseArtifactsOutput>true</UseArtifactsOutput>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<FileVersion Condition=" '$(GITHUB_RUN_NUMBER)' != '' ">$(VersionPrefix).$(GITHUB_RUN_NUMBER)</FileVersion>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ReportGeneratorOutputMarkdown Condition=" '$(ReportGeneratorOutputMarkdown)' == '' AND '$(GITHUB_SHA)' != '' ">true</ReportGeneratorOutputMarkdown>
<ReportGeneratorReportTypes>HTML</ReportGeneratorReportTypes>
<ReportGeneratorReportTypes Condition=" '$(ReportGeneratorOutputMarkdown)' == 'true' ">$(ReportGeneratorReportTypes);MarkdownSummaryGitHub</ReportGeneratorReportTypes>
<ReportGeneratorTargetDirectory>$([System.IO.Path]::Combine($(OutputPath), 'coverage'))</ReportGeneratorTargetDirectory>
<ReportGeneratorTargetDirectory>$([System.IO.Path]::Combine($(ArtifactsPath), 'coverage'))</ReportGeneratorTargetDirectory>
<_MarkdownSummaryPrefix>&lt;details&gt;&lt;summary&gt;:chart_with_upwards_trend: &lt;b&gt;$(AssemblyName) Code Coverage report&lt;/b&gt;&lt;/summary&gt;</_MarkdownSummaryPrefix>
<_MarkdownSummarySuffix>&lt;/details&gt;</_MarkdownSummarySuffix>
</PropertyGroup>
Expand Down
12 changes: 5 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,27 @@
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageVersion Include="MartinCostello.Testing.AwsLambdaTestServer" Version="0.7.1" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="7.0.10" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-preview.7.23375.6" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0-preview.7.23375.6" />
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="8.0.0-preview.7.23375.9" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0-preview.7.23375.6" />
<!--
HACK Workaround for https://github.com/aws/aws-lambda-dotnet/issues/920
-->
<PackageVersion Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Polly" Version="7.2.4" />
<PackageVersion Include="Refit" Version="7.0.0" />
<PackageVersion Include="ReportGenerator" Version="5.1.25" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.507" />
<PackageVersion Include="System.Text.Json" Version="7.0.3" />
<PackageVersion Include="System.Text.Json" Version="8.0.0-preview.7.23375.6" />
<PackageVersion Include="xRetry" Version="1.9.0" />
<PackageVersion Include="xunit" Version="2.5.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(IsTestProject)' == 'true' ">
Expand Down
14 changes: 3 additions & 11 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#! /usr/bin/env pwsh
param(
[Parameter(Mandatory = $false)][string] $Configuration = "Release",
[Parameter(Mandatory = $false)][string] $OutputPath = "",
[Parameter(Mandatory = $false)][switch] $UseManagedRuntime
)

Expand All @@ -12,11 +11,6 @@ $solutionPath = $PSScriptRoot
$sdkFile = Join-Path $solutionPath "global.json"

$dotnetVersion = (Get-Content $sdkFile | Out-String | ConvertFrom-Json).sdk.version

if ($OutputPath -eq "") {
$OutputPath = Join-Path $PSScriptRoot "artifacts"
}

$installDotNetSdk = $false;

if (($null -eq (Get-Command "dotnet" -ErrorAction SilentlyContinue)) -and ($null -eq (Get-Command "dotnet.exe" -ErrorAction SilentlyContinue))) {
Expand Down Expand Up @@ -81,7 +75,7 @@ function DotNetTest {
$additionalArgs += "GitHubActions;report-warnings=false"
}

& $dotnet test $Project --output $OutputPath --configuration $Configuration $additionalArgs
& $dotnet test $Project --configuration $Configuration $additionalArgs

if ($LASTEXITCODE -ne 0) {
throw "dotnet test failed with exit code $LASTEXITCODE"
Expand All @@ -91,8 +85,6 @@ function DotNetTest {
function DotNetPublish {
param([string]$Project)

$publishPath = (Join-Path $OutputPath "publish")

$additionalArgs = @()

if ($IsLinux -And (-Not $UseManagedRuntime)) {
Expand All @@ -104,7 +96,7 @@ function DotNetPublish {
$additionalArgs += "/p:PublishReadyToRun=true"
}

& $dotnet publish $Project --output $publishPath --configuration $Configuration $additionalArgs
& $dotnet publish $Project $additionalArgs

if ($LASTEXITCODE -ne 0) {
throw "dotnet publish failed with exit code $LASTEXITCODE"
Expand All @@ -122,7 +114,7 @@ $publishProjects = @(

Write-Host "Publishing solution..." -ForegroundColor Green
ForEach ($project in $publishProjects) {
DotNetPublish $project $Configuration
DotNetPublish $project
}

Write-Host "Testing $($testProjects.Count) project(s)..." -ForegroundColor Green
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.400",
"version": "8.0.100-preview.7.23376.3",
"allowPrerelease": false,
"rollForward": "latestMajor"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static IServiceCollection AddHttpClients(this IServiceCollection services
services.AddSingleton<IHttpContentSerializer>((p) =>
{
var options = new JsonSerializerOptions(JsonSerializerDefaults.Web);
options.AddContext<ApplicationJsonSerializerContext>();
options.TypeInfoResolverChain.Add(ApplicationJsonSerializerContext.Default);

return new SystemTextJsonContentSerializer(options);
});
Expand Down
4 changes: 3 additions & 1 deletion src/LondonTravel.Skill/Intents/CommuteIntent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace MartinCostello.LondonTravel.Skill.Intents;
/// </summary>
internal sealed class CommuteIntent : IIntent
{
private static readonly CompositeFormat CommuteIntentPrefixFormat = CompositeFormat.Parse(Strings.CommuteIntentPrefixFormat);

/// <summary>
/// Initializes a new instance of the <see cref="CommuteIntent"/> class.
/// </summary>
Expand Down Expand Up @@ -96,7 +98,7 @@ private async Task<SkillResponse> CommuteAsync(ICollection<string> favoriteLines
if (hasMultipleStatuses)
{
string displayName = Verbalizer.LineName(line.Name, asTitleCase: true);
text = string.Format(CultureInfo.CurrentCulture, Strings.CommuteIntentPrefixFormat, displayName, text);
text = string.Format(CultureInfo.CurrentCulture, CommuteIntentPrefixFormat, displayName, text);
}

paragraphs.Add(text);
Expand Down
4 changes: 3 additions & 1 deletion src/LondonTravel.Skill/Lines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace MartinCostello.LondonTravel.Skill;
/// </summary>
internal static class Lines
{
private static readonly CompositeFormat StatusIntentCardTitleFormat = CompositeFormat.Parse(Strings.StatusIntentCardTitleFormat);

/// <summary>
/// Returns whether the specified line name refers to the Docklands Light Railway.
/// </summary>
Expand Down Expand Up @@ -148,6 +150,6 @@ public static string ToCardTitle(string name)
suffix = Strings.LineSuffixUpper;
}

return string.Format(CultureInfo.CurrentCulture, Strings.StatusIntentCardTitleFormat, name, suffix);
return string.Format(CultureInfo.CurrentCulture, StatusIntentCardTitleFormat, name, suffix);
}
}
2 changes: 1 addition & 1 deletion src/LondonTravel.Skill/LondonTravel.Skill.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<NoWarn>$(NoWarn);CA1822</NoWarn>
<OutputType>Exe</OutputType>
<RootNamespace>MartinCostello.LondonTravel.Skill</RootNamespace>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/LondonTravel.Skill/Verbalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace MartinCostello.LondonTravel.Skill;
/// </summary>
internal static class Verbalizer
{
private static readonly CompositeFormat LineNameWithoutPrefixFormat = CompositeFormat.Parse(Strings.LineNameWithoutPrefixFormat);
private static readonly CompositeFormat LineNameWithPrefixFormat = CompositeFormat.Parse(Strings.LineNameWithPrefixFormat);

/// <summary>
/// Returns the spoken version of the specified line name.
/// </summary>
Expand Down Expand Up @@ -49,8 +52,8 @@ internal static string LineName(string name, bool asTitleCase = false)

return
asTitleCase ?
string.Format(CultureInfo.CurrentCulture, Strings.LineNameWithoutPrefixFormat, spokenName, suffix) :
string.Format(CultureInfo.CurrentCulture, Strings.LineNameWithPrefixFormat, prefix, spokenName, suffix);
string.Format(CultureInfo.CurrentCulture, LineNameWithoutPrefixFormat, spokenName, suffix) :
string.Format(CultureInfo.CurrentCulture, LineNameWithPrefixFormat, prefix, spokenName, suffix);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/LondonTravel.Skill/aws-lambda-tools-defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profile": "alexa-london-travel",
"region": "eu-west-1",
"configuration": "Release",
"framework": "net7.0",
"framework": "net8.0",
"function-runtime": "provided.al2",
"function-memory-size": 256,
"function-timeout": 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);CA1707;SA1600</NoWarn>
<RootNamespace>LondonTravel.Skill.EndToEndTests</RootNamespace>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.Lambda" />
Expand Down
2 changes: 1 addition & 1 deletion test/LondonTravel.Skill.Tests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void Configure(IServiceCollection services)

if (!cancellationTokenSource.IsCancellationRequested)
{
cancellationTokenSource.Cancel();
await cancellationTokenSource.CancelAsync();
}
});

Expand Down
4 changes: 2 additions & 2 deletions test/LondonTravel.Skill.Tests/LondonTravel.Skill.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);CA1062;CA1707;CA2007;CA2234;SA1600</NoWarn>
<RootNamespace>MartinCostello.LondonTravel.Skill</RootNamespace>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\LondonTravel.Skill\LondonTravel.Skill.csproj" />
Expand All @@ -25,7 +25,7 @@
</ItemGroup>
<PropertyGroup>
<CollectCoverage>true</CollectCoverage>
<CoverletOutput>$([System.IO.Path]::Combine($(OutputPath), 'coverage', 'coverage'))</CoverletOutput>
<CoverletOutput>$([System.IO.Path]::Combine($(ArtifactsPath), 'coverage', 'coverage'))</CoverletOutput>
<CoverletOutputFormat>cobertura,json</CoverletOutputFormat>
<Exclude>[Alexa.NET*]*,[Amazon.Lambda*]*,[LondonTravel.Skill.EndToEndTests]*,[Refit*]*,[xunit.*]*</Exclude>
<Threshold>93</Threshold>
Expand Down

0 comments on commit 9d1788d

Please sign in to comment.