diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 125cf5a..0bb5718 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -40,7 +40,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Build solution run: ./build.sh --target compile --no-logo diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 59902ff..32e5d33 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -24,7 +24,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Get semantic release version uses: cycjimmy/semantic-release-action@v3 @@ -51,7 +51,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Run unit tests run: ./build.sh --target test --no-logo @@ -69,7 +69,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Semantic release uses: cycjimmy/semantic-release-action@v3 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 83f840c..8a35875 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -24,7 +24,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Run unit tests run: ./build.sh --target test --no-logo \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index 0fd11a4..6e8ff52 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,30 +4,30 @@ true - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + - - + + - - + + all - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers diff --git a/build/_build.csproj b/build/_build.csproj index 5cef09b..f70a371 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -16,7 +16,7 @@ - + diff --git a/samples/WebApiSample/Program.cs b/samples/WebApiSample/Program.cs index 82f3680..b9c01e5 100644 --- a/samples/WebApiSample/Program.cs +++ b/samples/WebApiSample/Program.cs @@ -75,9 +75,11 @@ // You can choose to include additional metrics (other than the request total duration) conditionally. requestOptions.IncludeCustomMetrics = query.ContainsKey("custom"); }); - + // Add any required origins for the Timing-Allow-Origin header. +#pragma warning disable CA1861 options.TimingAllowOrigins = new[] { "https://example.com" }; +#pragma warning restore CA1861 // You may want to invoke the callbacks with the timings to record them elsewhere, // even if you do not want to send the Server-Timing header in the response. diff --git a/samples/WebApiSample/WebApiSample.csproj b/samples/WebApiSample/WebApiSample.csproj index de92551..0eb38a1 100644 --- a/samples/WebApiSample/WebApiSample.csproj +++ b/samples/WebApiSample/WebApiSample.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 latest enable enable diff --git a/test/Timingz.PerformanceTests/Timingz.PerformanceTests.csproj b/test/Timingz.PerformanceTests/Timingz.PerformanceTests.csproj index 2adbf26..df159bb 100644 --- a/test/Timingz.PerformanceTests/Timingz.PerformanceTests.csproj +++ b/test/Timingz.PerformanceTests/Timingz.PerformanceTests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 $(NoWarn);CS1591 Exe false diff --git a/test/Timingz.Tests/ManualMetricTests.cs b/test/Timingz.Tests/ManualMetricTests.cs index 4637451..244ecd6 100644 --- a/test/Timingz.Tests/ManualMetricTests.cs +++ b/test/Timingz.Tests/ManualMetricTests.cs @@ -102,7 +102,7 @@ public void DurationHasValueOnceStopped() [Fact] public void IsRunningUpdatedWhenStartingAndStopping() { - IManualMetric metric = new ManualMetric(Name, Description); + var metric = new ManualMetric(Name, Description); metric.IsRunning.Should().BeFalse(); metric.Start(); diff --git a/test/Timingz.Tests/ServerTimingEventTests.cs b/test/Timingz.Tests/ServerTimingEventTests.cs index bb4408f..0e71340 100644 --- a/test/Timingz.Tests/ServerTimingEventTests.cs +++ b/test/Timingz.Tests/ServerTimingEventTests.cs @@ -28,9 +28,9 @@ public void ReadOnlyStateSetFromConstructorParameters() RemotePort = 80 } }; - httpContext.Request.Headers.Add("foo", "bar"); + httpContext.Request.Headers.Append("foo", "bar"); httpContext.Response.StatusCode = 200; - httpContext.Response.Headers.Add("foo", "bar"); + httpContext.Response.Headers.Append("foo", "bar"); var metric1 = new Metric("foo"); var metric2 = new Metric("bar"); diff --git a/test/Timingz.Tests/ServerTimingMiddlewareTests.cs b/test/Timingz.Tests/ServerTimingMiddlewareTests.cs index a7734e3..81a2635 100644 --- a/test/Timingz.Tests/ServerTimingMiddlewareTests.cs +++ b/test/Timingz.Tests/ServerTimingMiddlewareTests.cs @@ -346,12 +346,14 @@ public LogMessage(LogLevel logLevel, string message, Exception exception) private sealed class TestLogger : ILogger { - private readonly IList _logMessages = new List(); + private readonly List _logMessages = []; - public IList GetLogMessages() +#pragma warning disable CA1859 + public IReadOnlyList GetLogMessages() { - lock (_logMessages) return _logMessages.ToList(); + lock (_logMessages) return _logMessages.AsReadOnly(); } +#pragma warning restore CA1859 public IDisposable BeginScope(TState state) => null; diff --git a/test/Timingz.Tests/Timingz.Tests.csproj b/test/Timingz.Tests/Timingz.Tests.csproj index 0956878..459e10b 100644 --- a/test/Timingz.Tests/Timingz.Tests.csproj +++ b/test/Timingz.Tests/Timingz.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 false enable