Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET 8 preparation #484

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/approve-and-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: approve-and-merge

on:
pull_request:
branches: [ main ]
branches: [ main, dotnet-vnext ]

env:
REVIEWER_LOGIN: ${{ vars.REVIEWER_USER_NAME }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [ main ]
tags: [ v* ]
pull_request:
branches: [ main ]
branches: [ main, dotnet-vnext ]
workflow_dispatch:

env:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
file: ./artifacts/coverage.net6.0.cobertura.xml
file: ./artifacts/coverage/coverage.net6.0.cobertura.xml
flags: ${{ matrix.os_name }}

- name: Publish artifacts
Expand All @@ -78,6 +78,7 @@ jobs:
with:
name: packages-${{ matrix.os_name }}
path: ./artifacts/packages
if-no-files-found: error

validate-packages:
needs: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-ql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [ main, dotnet-vnext ]
schedule:
- cron: '0 6 * * MON'
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: dependency-review

on:
pull_request:
branches: [ main ]
branches: [ main, dotnet-vnext ]

permissions:
contents: read
Expand Down
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
</PropertyGroup>
<PropertyGroup>
<CollectCoverage>true</CollectCoverage>
<CoverletOutput Condition=" '$(OutputPath)' != '' ">$(OutputPath)\</CoverletOutput>
<CoverletOutputFormat>cobertura,json</CoverletOutputFormat>
<Exclude>[Benchmark]*,[*.Tests]*,[xunit.*]*</Exclude>
<ExcludeByAttribute>System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute</ExcludeByAttribute>
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup Condition=" '$(CollectCoverage)' == 'true' ">
<CoverletOutput>$([System.IO.Path]::Combine($(OutputPath), 'coverage', 'coverage'))</CoverletOutput>
<ReportGeneratorOutputMarkdown Condition=" '$(ReportGeneratorOutputMarkdown)' == '' AND '$(GITHUB_SHA)' != '' ">true</ReportGeneratorOutputMarkdown>
<ReportGeneratorReportTypes>HTML</ReportGeneratorReportTypes>
<ReportGeneratorReportTypes Condition=" '$(ReportGeneratorOutputMarkdown)' == 'true' ">$(ReportGeneratorReportTypes);MarkdownSummaryGitHub</ReportGeneratorReportTypes>
Expand Down
2 changes: 1 addition & 1 deletion JustEat.StatsD.ruleset
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="JustEat.StatsD Rules" Description="This rule set contains rules for the Just Eat JustEat.StatsD solution." ToolsVersion="16.0">
<RuleSet Name="JustEat.StatsD Rules" Description="This rule set contains rules for the Just Eat JustEat.StatsD solution." ToolsVersion="17.0">
<IncludeAll Action="Warning" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1062" Action="None" />
Expand Down
11 changes: 5 additions & 6 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@

param(
[Parameter(Mandatory = $false)][string] $Configuration = "Release",
[Parameter(Mandatory = $false)][string] $VersionSuffix = "",
[Parameter(Mandatory = $false)][string] $OutputPath = "",
[Parameter(Mandatory = $false)][switch] $SkipTests
)

$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"

$solutionPath = Split-Path $MyInvocation.MyCommand.Definition
$solutionPath = $PSScriptRoot
$sdkFile = Join-Path $solutionPath "global.json"

$libraryProject = Join-Path $solutionPath "src\JustEat.StatsD\JustEat.StatsD.csproj"
$libraryProject = Join-Path $solutionPath "src" "JustEat.StatsD" "JustEat.StatsD.csproj"

$testProjects = @(
(Join-Path $solutionPath "tests\JustEat.StatsD.Tests\JustEat.StatsD.Tests.csproj")
(Join-Path $solutionPath "tests" "JustEat.StatsD.Tests" "JustEat.StatsD.Tests.csproj")
)

$dotnetVersion = (Get-Content $sdkFile | Out-String | ConvertFrom-Json).sdk.version
Expand Down Expand Up @@ -51,7 +50,7 @@ else {
if ($installDotNetSdk -eq $true) {

$env:DOTNET_INSTALL_DIR = Join-Path "$(Convert-Path "$PSScriptRoot")" ".dotnetcli"
$sdkPath = Join-Path $env:DOTNET_INSTALL_DIR "sdk\$dotnetVersion"
$sdkPath = Join-Path $env:DOTNET_INSTALL_DIR "sdk" $dotnetVersion

if (!(Test-Path $sdkPath)) {
if (!(Test-Path $env:DOTNET_INSTALL_DIR)) {
Expand Down Expand Up @@ -127,7 +126,7 @@ Write-Host "Packaging library..." -ForegroundColor Green
DotNetPack $libraryProject

Write-Host "Running tests..." -ForegroundColor Green
Remove-Item -Path (Join-Path $OutputPath "coverage.*.json") -Force -ErrorAction SilentlyContinue | Out-Null
Remove-Item -Path (Join-Path $OutputPath "coverage" "coverage.*.json") -Force -ErrorAction SilentlyContinue | Out-Null
ForEach ($testProject in $testProjects) {
DotNetTest $testProject
}
8 changes: 2 additions & 6 deletions src/JustEat.StatsD/TagsFormatters/StatsDTagsFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ private bool TryWriteTags(ref Buffer<char> buffer, in Dictionary<string, string?

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool TryWriteTagsSeparator(ref Buffer<char> buffer, int index, in Dictionary<string, string?> tags) =>
!IsLastTag(index, tags)
? buffer.TryWrite(_tagsSeparator)
: true;
IsLastTag(index, tags) || buffer.TryWrite(_tagsSeparator);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsLastTag(int index, in Dictionary<string, string?> tags) =>
Expand All @@ -135,9 +133,7 @@ private bool TryWriteTags(ref Buffer<char> buffer, in Dictionary<string, string?

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool TryWriteTagValueIfNeeded(ref Buffer<char> buffer, KeyValuePair<string, string?> tag) =>
tag.Value != null
? buffer.TryWrite(_keyValueSeparator) && buffer.TryWriteString(tag.Value!)
: true;
tag.Value == null || buffer.TryWrite(_keyValueSeparator) && buffer.TryWriteString(tag.Value!);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool AreTagsPresent(in Dictionary<string, string?>? tags) =>
Expand Down
2 changes: 1 addition & 1 deletion tests/Benchmark/UdpTransportBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class UdpTransportBenchmark
private SocketTransport? _transport;
private SocketTransport? _transportSwitched;

private class MillisecondSwitcher : IEndPointSource
private sealed class MillisecondSwitcher : IEndPointSource
{
private readonly IEndPointSource _endpointSource1;
private readonly IEndPointSource _endpointSource2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace JustEat.StatsD;

public class BufferBasedStatsDPublisherTests
{
private readonly FakeTransport _transport = new FakeTransport();
private readonly StatsDConfiguration _configuration = new StatsDConfiguration { Prefix = "test" };
private readonly FakeTransport _transport = new();
private readonly StatsDConfiguration _configuration = new() { Prefix = "test" };
private readonly BufferBasedStatsDPublisher _sut;

public BufferBasedStatsDPublisherTests()
Expand Down Expand Up @@ -48,7 +48,7 @@ public void TestTimingSampled_Long()
_transport.Messages.ShouldHaveSingleItem("test.timing:1234|ms|@0.99");
}

private class FakeTransport : IStatsDTransport
private sealed class FakeTransport : IStatsDTransport
{
public List<string> Messages { get; } = new List<string>();

Expand Down
6 changes: 2 additions & 4 deletions tests/JustEat.StatsD.Tests/SocketTransportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public static void SocketTransportIsNoopForNullEndpoint()
transport.Send("teststat:1|c");
}

private static IEndPointSource LocalStatsEndpoint()
{
return new SimpleEndpointSource(new IPEndPoint(IPAddress.Loopback, StatsDConfiguration.DefaultPort));
}
private static SimpleEndpointSource LocalStatsEndpoint()
=> new(new IPEndPoint(IPAddress.Loopback, StatsDConfiguration.DefaultPort));
}
4 changes: 2 additions & 2 deletions tests/JustEat.StatsD.Tests/Utf8TagsFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace JustEat.StatsD;
public static class Utf8TagsFormatterTests
{
private static readonly byte[] Buffer = new byte[512];
private static readonly Dictionary<string, string?> AnyValidTags = new Dictionary<string, string?>
private static readonly Dictionary<string, string?> AnyValidTags = new()
{
["foo"] = "bar",
["empty"] = null,
Expand Down Expand Up @@ -292,7 +292,7 @@ public enum TagsFormatter
SignalFx,
}

private class AlwaysNullStatsDTagsFormatter : IStatsDTagsFormatter
private sealed class AlwaysNullStatsDTagsFormatter : IStatsDTagsFormatter
{
public bool AreTrailing { get; }

Expand Down
2 changes: 1 addition & 1 deletion tests/JustEat.StatsD.Tests/WhenRegisteringStatsD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public static void AddStatsDThrowsIfServicesIsNull()
Assert.Throws<ArgumentNullException>("services", () => services!.AddStatsD());
}

private static IServiceProvider Configure(Action<IServiceCollection> registration)
private static ServiceProvider Configure(Action<IServiceCollection> registration)
{
var services = new ServiceCollection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void ItShouldBeAbleToSendMessagesOfArbitraryLength(char ch, int count)
fakeTransport.TimesCalled.ShouldBe(1);
}

private class FakeTransport : IStatsDTransport
private sealed class FakeTransport : IStatsDTransport
{
public int TimesCalled { get; private set; }

Expand Down
2 changes: 1 addition & 1 deletion tests/JustEat.StatsD.Tests/WhenUsingUdpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void EndpointSwitchShouldNotCauseExceptionsParallel()
});
}

private class MillisecondSwitcher : IEndPointSource
private sealed class MillisecondSwitcher : IEndPointSource
{
private readonly IEndPointSource _endpointSource1;
private readonly IEndPointSource _endpointSource2;
Expand Down
Loading