diff --git a/.github/pipelines/dotnet-initialize.yml b/.github/pipelines/dotnet-initialize.yml
index 1dda323e..c166fcb2 100644
--- a/.github/pipelines/dotnet-initialize.yml
+++ b/.github/pipelines/dotnet-initialize.yml
@@ -11,9 +11,9 @@ steps:
- task: NuGetAuthenticate@1
displayName: NuGet Authenticate
- task: UseDotNet@2
- displayName: Temporarily install .NET 7 SDK while dual targeting
+ displayName: Temporarily install .NET 8 SDK while dual targeting
inputs:
- version: "7.0.405"
+ version: "8.0.404"
- task: UseDotNet@2
displayName: Use .NET SDK from global.json
inputs:
diff --git a/.github/pipelines/github-forward.yml b/.github/pipelines/github-forward.yml
index 8d48dfdd..e7740ebf 100644
--- a/.github/pipelines/github-forward.yml
+++ b/.github/pipelines/github-forward.yml
@@ -87,7 +87,7 @@ extends:
Title: GitHub Forward Integration - $(GITHUBCOMMIT)
Description: GitHub forward integration Pull Request for commit '$(GITHUBCOMMIT)'
SkipIfNoChangesFound: false
- WorkItemId: "8430180"
+ WorkItemId: "9421495"
AutoCompleteUserId: 75d3c7a0-2045-6bf0-b50e-3ab2cf9ae644
Pat: $(OfficeOcCodeAccessCorpNet)
MergeStrategy: noFastForward
diff --git a/.github/pipelines/github-packageupdate.yml b/.github/pipelines/github-packageupdate.yml
index e9276718..eed89db7 100644
--- a/.github/pipelines/github-packageupdate.yml
+++ b/.github/pipelines/github-packageupdate.yml
@@ -53,6 +53,6 @@ extends:
TargetBranchName: main
Title: Automatic NuGet package update
Description: update of NuGet packages
- WorkItemId: "9127473"
+ WorkItemId: "9421495"
Pat: $(omexgithubbotinternalpat)
MergeStrategy: "0"
diff --git a/.github/pipelines/github-semmle.yml b/.github/pipelines/github-semmle.yml
index 6f82e10e..69f5a103 100644
--- a/.github/pipelines/github-semmle.yml
+++ b/.github/pipelines/github-semmle.yml
@@ -37,6 +37,10 @@ extends:
steps:
- checkout: self
clean: true
+ - task: UseDotNet@2
+ displayName: Temporarily install .NET 8 SDK while dual targeting
+ inputs:
+ version: "8.0.404"
- task: UseDotNet@2
displayName: Use .NET SDK from global.json
inputs:
diff --git a/.github/pipelines/sf-initialize.yml b/.github/pipelines/sf-initialize.yml
index f1fa39ef..addb502b 100644
--- a/.github/pipelines/sf-initialize.yml
+++ b/.github/pipelines/sf-initialize.yml
@@ -3,14 +3,14 @@
parameters:
- name: SdkVersion
type: string
- default: "10.1.2175.9590"
+ default: "10.1.2448.9590"
steps:
- task: PowerShell@2
displayName: Install SF ${{parameters.SdkVersion}}
inputs:
targetType: 'inline'
script: |
- Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser
+ Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -OutFile setup.exe -Uri https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/MicrosoftServiceFabric.${{parameters.SdkVersion}}.exe
.\setup.exe /accepteula /force /quiet
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 16655151..fed09964 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -23,14 +23,19 @@ jobs:
IsReleaseBuild: ${{ matrix.configuration == 'Release' && github.event_name == 'release' && !github.event.release.prerelease && github.ref == 'refs/heads/master' }}
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-dotnet@v4
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ - name: Install .NET 8 SDK
+ uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- # Install SF SDK
- - name: Install SF
+ - name: Install .NET 9 SDK
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: '9.0.x'
+ - name: Install SF SDK
shell: powershell
- run: |
+ run: |
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -OutFile setup.exe -Uri https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/MicrosoftServiceFabric.10.1.2448.9590.exe
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index a74b5149..954ffa27 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -31,9 +31,14 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- - uses: actions/setup-dotnet@v4
+ - name: Install .NET 8 SDK
+ uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
+ - name: Install .NET 9 SDK
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: '9.0.x'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
diff --git a/Directory.Build.props b/Directory.Build.props
index ce00ccbc..7af0dd40 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -2,9 +2,8 @@
$([System.IO.Path]::GetDirectoryName($([MSBuild]::GetPathOfFileAbove('global.json', '$(MSBuildProjectDirectory)'))))
-
-
- net8.0
+
+ net9.0
net8.0
$(LatestSupportedDotNetVersion)
$(LatestSupportedDotNetVersion);$(OldestSupportedDotNetVersion)
@@ -14,7 +13,7 @@
$(NetCoreVersions)
-
+
AnyCPU
AnyCPU
prompt
@@ -25,16 +24,16 @@
latest
enable
-
+
$(NetStandardVersions.Contains('$(TargetFramework)'))
-
+
true
false
$(MSBuildThisFileDirectory)\OmexOpenSource.snk
, PublicKey=00240000048000009400000006020000002400005253413100040000010001004d77aff3ec12650e8979fb873e4b409556a1a650482e6d4dfcf9fea3c87dc334dc2f08ab4820ad3555b949a172553484f5f8fecd302db2907a5d8e3c33d394276c05e18865c5776e0c1f04bba8c4d3e4b12bc44b70e70dc076cc69611b04368d7eff2e83f5b016db366f9d572dad24f09adc6ae732802958048b69727561d1bd
-
+
$(MSBuildThisFileDirectory)\bin\$(MSBuildProjectName)
$(MSBuildThisFileDirectory)\obj\$(MSBuildProjectName)
$(MSBuildThisFileDirectory)\nuget
@@ -58,7 +57,7 @@
$(MSBuildProjectName)
Omex
-
+
false
git
https://github.com/microsoft/Omex
@@ -74,7 +73,7 @@
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
$(MSBuildThisFileDirectory)
-
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 59046449..e1eed48e 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -5,46 +5,46 @@
true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/global.json b/global.json
index b8298149..f6578894 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.404",
+ "version": "9.0.100",
"rollForward": "latestMajor"
}
}
diff --git a/tests/Activities.UnitTests/Internal/ActivityListenerInitializerServiceTests.cs b/tests/Activities.UnitTests/Internal/ActivityListenerInitializerServiceTests.cs
index 940a0d39..a68190d9 100644
--- a/tests/Activities.UnitTests/Internal/ActivityListenerInitializerServiceTests.cs
+++ b/tests/Activities.UnitTests/Internal/ActivityListenerInitializerServiceTests.cs
@@ -52,7 +52,7 @@ public async Task ActivityListeners_ControlsActivityCreation()
// check that Activity from Diagnostic listener also captured
using (DiagnosticListener listener = new(nameof(ActivityListeners_ControlsActivityCreation)))
{
- Activity activity = new("DiagnosticsListenerActivity");
+ using Activity activity = new("DiagnosticsListenerActivity");
listener.StartActivity(activity, null);
mockStartObserver.Verify(s => s.OnStart(activity, null), Times.Once);
diff --git a/tests/Activities.UnitTests/Internal/ActivityMetricsSenderTests.cs b/tests/Activities.UnitTests/Internal/ActivityMetricsSenderTests.cs
index 39134fba..4a4f77bd 100644
--- a/tests/Activities.UnitTests/Internal/ActivityMetricsSenderTests.cs
+++ b/tests/Activities.UnitTests/Internal/ActivityMetricsSenderTests.cs
@@ -179,15 +179,14 @@ public void SendActivityMetric_WithSendParentName_ProducesMetricPointWithParentN
Listener listener = new();
string? parentName = hasParentName ? nameof(parentName) : null;
- if (hasParentActivity)
- {
- Activity parent = new(parentName!);
- parent.Start();
- }
+ using Activity? parent = hasParentActivity ? new(parentName!) : null;
+ parent?.Start();
- Activity activity = new(nameof(activity));
+ using Activity activity = new(nameof(activity));
activity.Start().Stop();
+ parent?.Stop();
+
sender.SendActivityMetric(activity);
// 3. Assert
diff --git a/tests/Activities.UnitTests/Internal/ActivityObserverTests.cs b/tests/Activities.UnitTests/Internal/ActivityObserverTests.cs
index f6ced91a..6c0f8d95 100644
--- a/tests/Activities.UnitTests/Internal/ActivityObserverTests.cs
+++ b/tests/Activities.UnitTests/Internal/ActivityObserverTests.cs
@@ -22,7 +22,7 @@ public class ActivityObserverTests
[TestMethod]
public void OnStop_CallsLogActivityStop()
{
- Activity activity = new(nameof(OnStop_CallsLogActivityStop));
+ using Activity activity = new(nameof(OnStop_CallsLogActivityStop));
(ActivityObserver observer, _, Mock senderMock) = CreateObserver();
observer.OnStop(activity, null);
@@ -53,7 +53,7 @@ public void OnStart_LogsStart()
[DataRow(false, ActivityResult.ExpectedError)]
public void OnStop_LogsStop(bool isSuccesful, ActivityResult? result)
{
- Activity activity = new Activity(nameof(OnStop_LogsStop))
+ using Activity activity = new Activity(nameof(OnStop_LogsStop))
.Start()
.SetBaggage("SomeValue", "BaggageValue")
.SetTag("SomeTag", "TagValue");
diff --git a/tests/Activities.UnitTests/ServiceCollectionTests.cs b/tests/Activities.UnitTests/ServiceCollectionTests.cs
index b5cd0aa4..7aa934eb 100644
--- a/tests/Activities.UnitTests/ServiceCollectionTests.cs
+++ b/tests/Activities.UnitTests/ServiceCollectionTests.cs
@@ -1,16 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Diagnostics;
using System;
-using Microsoft.Omex.Extensions.Abstractions.Activities.Processing;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Omex.Extensions.Abstractions.Activities.Processing;
using Microsoft.Omex.Extensions.Testing.Helpers;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.Omex.Extensions.Activities.UnitTests
{
@@ -45,7 +45,7 @@ public void AddOmexActivitySource_ActivityCreationEnabled()
{
Task task = CreateHost().RunAsync();
- Activity? activity = new ActivitySource("Source")
+ using Activity? activity = new ActivitySource("Source")
.StartActivity(nameof(AddOmexActivitySource_HostedServicesRegistered));
NullableAssert.IsNotNull(activity, "Activity creation enabled after host started");
diff --git a/tests/Diagnostics.HealthChecks.AspNetCore.UnitTests/Microsoft.Omex.Extensions.Diagnostics.HealthChecks.AspNetCore.UnitTests.csproj b/tests/Diagnostics.HealthChecks.AspNetCore.UnitTests/Microsoft.Omex.Extensions.Diagnostics.HealthChecks.AspNetCore.UnitTests.csproj
index 465f7669..12a9d1f5 100644
--- a/tests/Diagnostics.HealthChecks.AspNetCore.UnitTests/Microsoft.Omex.Extensions.Diagnostics.HealthChecks.AspNetCore.UnitTests.csproj
+++ b/tests/Diagnostics.HealthChecks.AspNetCore.UnitTests/Microsoft.Omex.Extensions.Diagnostics.HealthChecks.AspNetCore.UnitTests.csproj
@@ -1,6 +1,6 @@
-
+
- $(NetCoreVersions)
+ $(UnitTestTargetFrameworks)
x64
diff --git a/tests/Diagnostics.HealthChecks.UnitTests/CertificatesValidityHealthCheckTests.cs b/tests/Diagnostics.HealthChecks.UnitTests/CertificatesValidityHealthCheckTests.cs
index 0a66ce1e..690d0bf9 100644
--- a/tests/Diagnostics.HealthChecks.UnitTests/CertificatesValidityHealthCheckTests.cs
+++ b/tests/Diagnostics.HealthChecks.UnitTests/CertificatesValidityHealthCheckTests.cs
@@ -122,7 +122,12 @@ public async Task CheckHealthAsync_ShouldReturnUnhealthy_WhenCertificateNotYetVa
[TestMethod]
public async Task CheckHealthAsync_ShouldReturnUnhealthy_WhenCertificateDoesNotHavePrivateKey()
{
+#if NET9_0_OR_GREATER
+ X509Certificate2 certWithoutPrivateKey = X509CertificateLoader.LoadCertificate(CreateCert(m_certSubjectName).Export(X509ContentType.Cert));
+#else
X509Certificate2 certWithoutPrivateKey = new(CreateCert(m_certSubjectName).Export(X509ContentType.Cert));
+#endif
+
m_certificateReaderMock.Setup(m => m.GetCertificateByCommonName(It.IsAny(), It.IsAny(), It.IsAny()))
.Returns(certWithoutPrivateKey);
diff --git a/tests/Hosting.Services.Web.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.Services.Web.UnitTests/HostBuilderExtensionsTests.cs
index fb6c30d1..bc8ceace 100644
--- a/tests/Hosting.Services.Web.UnitTests/HostBuilderExtensionsTests.cs
+++ b/tests/Hosting.Services.Web.UnitTests/HostBuilderExtensionsTests.cs
@@ -34,8 +34,10 @@ public void BuildStatelessWebService_UseUniqueServiceUrl_Failing()
[TestMethod]
public async Task BuildStatelessWebService_RegisterListeners()
{
- (string name, int port) httpListener1 = ("httpListener", 20080);
- (string name, int port) httpListener2 = ("httpsListener", 20443);
+ // Use random ports from private range.
+ Random random = new Random();
+ (string name, int port) httpListener1 = ("httpListener", random.Next(49152, 65535));
+ (string name, int port) httpListener2 = ("httpsListener", random.Next(49152, 65535));
SfConfigurationProviderHelper.SetPublishAddress();
SfConfigurationProviderHelper.SetPortVariable(httpListener1.name, httpListener1.port);
diff --git a/tests/Hosting.Services.Web.UnitTests/Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests.csproj b/tests/Hosting.Services.Web.UnitTests/Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests.csproj
index 46d93f9f..cfc00477 100644
--- a/tests/Hosting.Services.Web.UnitTests/Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests.csproj
+++ b/tests/Hosting.Services.Web.UnitTests/Microsoft.Omex.Extensions.Hosting.Services.Web.UnitTests.csproj
@@ -1,6 +1,6 @@
- $(NetCoreVersions)
+ $(UnitTestTargetFrameworks)
x64