diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index c155afb42..715388d4e 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -41,7 +41,7 @@ jobs: uses: actions/setup-dotnet@v5 with: dotnet-version: | - 6.x + 8.x 10.x - uses: actions/checkout@v6 with: @@ -72,8 +72,10 @@ jobs: CoverletOutputFormat: "opencover" # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682 shell: pwsh run: | - ./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoftgraph_msgraph-sdk-dotnet-core" /o:"microsoftgraph2" /d:sonar.scanner.scanAll=false /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/Microsoft.Graph.DotnetCore.Core.Test/coverage.opencover.xml" + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + ./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoftgraph_msgraph-sdk-dotnet-core" /o:"microsoftgraph2" /d:sonar.scanner.scanAll=false /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/Microsoft.Graph.DotnetCore.Core.Test/coverage.net8.0.opencover.xml" dotnet workload restore - dotnet build - dotnet test Microsoft.Graph.Core.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --framework net6.0 + dotnet build /p:UseSharedCompilation=false + dotnet test Microsoft.Graph.Core.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --framework net8.0 ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/validatePullRequest.yml b/.github/workflows/validatePullRequest.yml index 09f822fec..f96f7774c 100644 --- a/.github/workflows/validatePullRequest.yml +++ b/.github/workflows/validatePullRequest.yml @@ -16,17 +16,17 @@ permissions: jobs: build: name: Build and Test - runs-on: windows-2022 + runs-on: windows-latest env: solutionName: Microsoft.Graph.Core.sln relativePath: ./src/Microsoft.Graph.Core steps: - uses: actions/checkout@v6 - - name: Setup .NET 6 + - name: Setup .NET 8 uses: actions/setup-dotnet@v5 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Setup .NET 10 uses: actions/setup-dotnet@v5 @@ -45,7 +45,7 @@ jobs: languages: csharp - name: Install needed dotnet workloads - run: dotnet workload install android macos ios maccatalyst + run: dotnet workload install android ios maccatalyst - name: Restore nuget dependencies run: dotnet restore ${{ env.solutionName }} @@ -64,7 +64,7 @@ jobs: validate-trimming: name: Validate Project for Trimming - runs-on: windows-2022 + runs-on: windows-latest steps: - uses: actions/checkout@v6 @@ -74,5 +74,5 @@ jobs: dotnet-version: 10.x - name: Validate Trimming warnings - run: dotnet publish -c Release -r win-x64 /p:TreatWarningsAsErrors=true /warnaserror -f net9.0 + run: dotnet publish -c Release -r win-x64 /p:TreatWarningsAsErrors=true /warnaserror -f net10.0 working-directory: ./tests/Microsoft.Graph.DotnetCore.Core.Trimming \ No newline at end of file diff --git a/.gitignore b/.gitignore index db25e2506..f4710a97f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ *.userosscache *.sln.ide #*.snk -TestResults/* +**/TestResults/ .vs/* # UWP project files diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 05c4afe29..127ac87b5 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.2.6" + ".": "4.0.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6928e315b..6284411c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.0.0](https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/compare/3.2.6...4.0.0) (2026-05-07) + + +### ⚠ BREAKING CHANGES + +* Kiota upgraded to 2.0.0 which removes IAsyncParseNodeFactory interface. Internal implementation changes required in response handlers. + +### Features + +* upgrade Kiota to 2.0.0 and support packages ([e24b91f](https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/commit/e24b91fa145448c2758157b020afee8387b7a8e2)) + ## [3.2.6](https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/compare/3.2.5...3.2.6) (2026-04-29) diff --git a/Directory.Build.props b/Directory.Build.props index 0fced15f6..a9b2471ab 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - net6.0 + - $(MauiTargets);net6.0-android;net6.0-ios;net6.0-maccatalyst;net6.0-macos;net6.0-windows + $(MauiTargets);net10.0-android;net10.0-ios;net10.0-maccatalyst;net10.0-windows \ No newline at end of file diff --git a/docs/upgrade-guide-v3-to-v4.md b/docs/upgrade-guide-v3-to-v4.md new file mode 100644 index 000000000..b9fd836c4 --- /dev/null +++ b/docs/upgrade-guide-v3-to-v4.md @@ -0,0 +1,218 @@ +--- +title: "Microsoft Graph Core SDK Upgrade Guide: v3.x to v4.x" +applies-to: "msgraph-sdk-dotnet-core" +from-version: "3.2.x" +to-version: "4.0.0" +breaking-changes: + - removed-interface: IAsyncParseNodeFactory + - changed-kiota-version: "1.22.1 → 2.0.0" + - updated-identity-model: "8.16.0 → 8.18.0" + - updated-test-sdk: "17.13.0 → 18.5.1" + - pinned-xunit-runner: "2.8.2 (net462 compatibility)" +--- + +# Upgrade Guide: Microsoft Graph Core SDK v3.x to v4.x + +This guide covers the breaking changes introduced in version 4.0 of the Microsoft Graph Core SDK and provides instructions for updating your code. The primary breaking change is the upgrade to **Kiota 2.0.0**, which consolidates parse node factory interfaces and removes synchronous deserialization methods. + +--- + +## Summary of Breaking Changes + +| Area | Change | +|------|--------| +| **Kiota Dependency** | Upgraded from 1.22.1 to 2.0.0 | +| **IAsyncParseNodeFactory** | Merged into `IParseNodeFactory`; interface removed | +| **Parse Node Factory** | Casting removed; use `IParseNodeFactory` directly | +| **Response Handlers** | Updated: `AsyncMonitor`, `ResponseHandler`, `DeltaResponseHandler`, `UploadResponseHandler` | +| **Identity Model Packages** | Updated from 8.16.0 to 8.18.0 | +| **Test Dependencies** | Updated to support net8.0 and net10.0 | + +--- + +## Kiota 2.0 Dependency Upgrade + +Version 4.0 upgrades the Kiota packages from 1.22.1 to 2.0.0. This is a major version bump that includes breaking changes. See [Kiota Upgrade Guide: v1.x to v2.x](https://github.com/microsoft/kiota-dotnet/blob/main/docs/upgrade-guide-v1-to-v2.md) for comprehensive details. + +### Updated Package Versions + +| Package | v3.x | v4.x | +|---------|------|------| +| `Microsoft.Kiota.Abstractions` | 1.22.1 | 2.0.0 | +| `Microsoft.Kiota.Authentication.Azure` | 1.22.1 | 2.0.0 | +| `Microsoft.Kiota.Serialization.Json` | 1.22.1 | 2.0.0 | +| `Microsoft.Kiota.Serialization.Text` | 1.22.1 | 2.0.0 | +| `Microsoft.Kiota.Serialization.Form` | 1.22.1 | 2.0.0 | +| `Microsoft.Kiota.Http.HttpClientLibrary` | 1.22.1 | 2.0.0 | +| `Microsoft.Kiota.Serialization.Multipart` | 1.22.1 | 2.0.0 | +| `Microsoft.IdentityModel.Protocols.OpenIdConnect` | 8.16.0 | 8.18.0 | +| `Microsoft.IdentityModel.Validators` | 8.16.0 | 8.18.0 | +| `Microsoft.SourceLink.GitHub` | 8.0.0 | 10.0.203 | +| `System.Net.Http.WinHttpHandler` | 9.0.14 | 10.0.7 | + +**Action required:** Update your project's package references to the versions listed above. + +--- + +## IParseNodeFactory Interface Changes + +The `IAsyncParseNodeFactory` interface has been merged into `IParseNodeFactory` in Kiota 2.0. This SDK has been updated to use the consolidated interface directly without casting. + +### Before (v3.x) + +```csharp +// ResponseHandler example +public class ResponseHandler : IResponseHandler where T : IParsable, new() +{ + private readonly IAsyncParseNodeFactory _jsonParseNodeFactory; + + public ResponseHandler(IParseNodeFactory parseNodeFactory = null) + { + // Cast to IAsyncParseNodeFactory for async operations + _jsonParseNodeFactory = parseNodeFactory as IAsyncParseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; + } + + public async Task HandleResponseAsync(NativeResponseType response, Dictionary> errorMappings) + { + // ... + var jsonParseNode = await _jsonParseNodeFactory.GetRootParseNodeAsync(...); + // ... + } +} +``` + +### After (v4.x) + +```csharp +// ResponseHandler example +public class ResponseHandler : IResponseHandler where T : IParsable, new() +{ + private readonly IParseNodeFactory _jsonParseNodeFactory; + + public ResponseHandler(IParseNodeFactory parseNodeFactory = null) + { + // Direct assignment; no casting needed + _jsonParseNodeFactory = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; + } + + public async Task HandleResponseAsync(NativeResponseType response, Dictionary> errorMappings) + { + // ... + var jsonParseNode = await _jsonParseNodeFactory.GetRootParseNodeAsync(...); + // ... + } +} +``` + +### Migration Steps + +If you have custom response handler implementations or use response handlers directly: + +1. **Replace `IAsyncParseNodeFactory` with `IParseNodeFactory`** in field declarations and method parameters. +2. **Remove casting**: Change `parseNodeFactory as IAsyncParseNodeFactory` to direct null-coalescing `parseNodeFactory ??`. +3. **Verify `GetRootParseNodeAsync` calls**: The method signature remains the same; ensure it is awaited. + +**Example migration:** + +```csharp +// Before +private readonly IAsyncParseNodeFactory factory; +this.factory = parseNodeFactory as IAsyncParseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; + +// After +private readonly IParseNodeFactory factory; +this.factory = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; +``` + +--- + +## Updated Response Handlers + +The following response handler classes have been updated to use `IParseNodeFactory` directly: + +- **AsyncMonitor** — `src/Microsoft.Graph.Core/Requests/AsyncMonitor.cs` +- **ResponseHandler** — `src/Microsoft.Graph.Core/Requests/ResponseHandler.cs` +- **DeltaResponseHandler** — `src/Microsoft.Graph.Core/Requests/DeltaResponseHandler.cs` +- **UploadResponseHandler** — `src/Microsoft.Graph.Core/Requests/Upload/UploadResponseHandler.cs` + +If you extend or override any of these classes, ensure you follow the migration steps above. + +--- + +## Support Package Updates + +### Test Framework Updates + +- `Microsoft.NET.Test.Sdk`: 17.13.0 → 18.5.1 +- `coverlet.collector`: 6.0.4 → 10.0.0 +- `coverlet.msbuild`: 6.0.4 → 10.0.0 +- `Microsoft.VisualStudio.Threading.Analyzers`: 17.13.2 → 17.14.15 + +### Test Framework Compatibility Note + +**xunit.runner.visualstudio** is pinned to **2.8.2** instead of 3.1.5 to maintain compatibility with the `net462` target framework. If you upgrade your project to remove `net462` support, you may update this to 3.1.5 or later. + +--- + +## Quick Reference: Find and Replace + +| v3.x Pattern | v4.x Replacement | +|---|---| +| `: IAsyncParseNodeFactory` | `: IParseNodeFactory` | +| `as IAsyncParseNodeFactory ??` | `??` | +| `parseNodeFactory as IAsyncParseNodeFactory ??` | `parseNodeFactory ??` | + +--- + +## Common Compiler Errors After Upgrading + +### CS0246 — Type or namespace not found: IAsyncParseNodeFactory + +``` +error CS0246: The type or namespace name 'IAsyncParseNodeFactory' could not be found +``` + +**Fix:** Replace `IAsyncParseNodeFactory` with `IParseNodeFactory`. Remove any casting: + +```csharp +// Before +private readonly IAsyncParseNodeFactory factory; +this.factory = parseNodeFactory as IAsyncParseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; + +// After +private readonly IParseNodeFactory factory; +this.factory = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; +``` + +--- + +### CS0308 — Cannot use non-invocable member + +``` +error CS0308: The non-generic method 'GetFactory' cannot be used with type arguments +``` + +**Fix:** If you're using `ParseNodeFactoryRegistry.GetFactory`, refer to the [Kiota upgrade guide](https://github.com/microsoft/kiota-dotnet/blob/main/docs/upgrade-guide-v1-to-v2.md#parsenodeFactoryregistry-changes) for the updated method signature. The method now returns a tuple and is non-generic. + +--- + +## Validation Checklist + +After upgrading to v4.x: + +- [ ] Update all NuGet package references to the versions listed in [Updated Package Versions](#updated-package-versions) +- [ ] Replace `IAsyncParseNodeFactory` with `IParseNodeFactory` in your code +- [ ] Remove casting expressions `as IAsyncParseNodeFactory` +- [ ] Ensure all calls to `GetRootParseNodeAsync` are awaited +- [ ] Run `dotnet build` to verify compilation +- [ ] Run `dotnet test` to validate functionality +- [ ] Test custom response handler implementations if you have any + +--- + +## Related Resources + +- [Kiota .NET Upgrade Guide: v1.x to v2.x](https://github.com/microsoft/kiota-dotnet/blob/main/docs/upgrade-guide-v1-to-v2.md) +- [Microsoft Graph Core SDK Release Notes](../../CHANGELOG.md) +- [Microsoft Graph Documentation](https://developer.microsoft.com/graph) + diff --git a/pipelines/productionBuild.yml b/pipelines/productionBuild.yml index 4ad98e244..2f735ca9d 100644 --- a/pipelines/productionBuild.yml +++ b/pipelines/productionBuild.yml @@ -2,25 +2,14 @@ # Licensed under the MIT License. trigger: branches: - include: - - main - paths: - include: - - src/* - exclude: - - .github/* - - build/* - - docs/* - - pipelines/* - - scripts/* - - .gitignore - - CONTRIBUTING.md - - LICENSE.txt - - Microsoft.Graph.Core.sln - - README.md - - THIRD PARTY NOTICES - - appveyor.yml + exclude: # prevents normal branch CI runs + - '*' + tags: + include: # ex v3.24.0 + - "v*" + pr: none + variables: PACKAGE_NAME: 'microsoft.graph.core' PROJECT_PATH: '.\src\Microsoft.Graph.Core\Microsoft.Graph.Core.csproj' @@ -54,11 +43,11 @@ extends: clean: true fetchDepth: 1 - task: UseDotNet@2 - displayName: 'Use .NET 6' + displayName: 'Use .NET 8' inputs: - version: 6.x + version: 8.x - task: UseDotNet@2 - displayName: 'Use .NET 10 for trimming validation' + displayName: 'Use .NET 10' inputs: version: 10.x - task: PowerShell@2 @@ -78,7 +67,7 @@ extends: pwsh: true enabled: true - powershell: | - dotnet workload install android macos ios maccatalyst + dotnet workload install android ios maccatalyst displayName: 'Install needed dotnet workloads' - task: DotNetCoreCLI@2 displayName: 'dotnet restore' diff --git a/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj b/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj index 990706948..06ffce6eb 100644 --- a/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj +++ b/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj @@ -21,7 +21,7 @@ 35MSSharedLib1024.snk true - 3.2.6 + 4.0.0 @@ -31,7 +31,8 @@ - https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/blob/main/CHANGELOG.md - netstandard2.0;net462;$(MauiTargets) + netstandard2.0;netstandard2.1;net462;net8.0;net10.0 + $(TargetFrameworks);$(MauiTargets) true true true @@ -64,22 +65,22 @@ - - - - - - - - - - + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/Microsoft.Graph.Core/Requests/AsyncMonitor.cs b/src/Microsoft.Graph.Core/Requests/AsyncMonitor.cs index 83290c1b2..02c81602a 100644 --- a/src/Microsoft.Graph.Core/Requests/AsyncMonitor.cs +++ b/src/Microsoft.Graph.Core/Requests/AsyncMonitor.cs @@ -23,7 +23,7 @@ namespace Microsoft.Graph internal string monitorUrl; - private readonly IAsyncParseNodeFactory parseNodeFactory; + private readonly IParseNodeFactory parseNodeFactory; /// /// Construct an Async Monitor. /// @@ -34,7 +34,7 @@ public AsyncMonitor(IBaseClient client, string monitorUrl, IParseNodeFactory par { this.client = client; this.monitorUrl = monitorUrl; - this.parseNodeFactory = parseNodeFactory as IAsyncParseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; + this.parseNodeFactory = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; } /// diff --git a/src/Microsoft.Graph.Core/Requests/DeltaResponseHandler.cs b/src/Microsoft.Graph.Core/Requests/DeltaResponseHandler.cs index 40a5f0059..e8e19343b 100644 --- a/src/Microsoft.Graph.Core/Requests/DeltaResponseHandler.cs +++ b/src/Microsoft.Graph.Core/Requests/DeltaResponseHandler.cs @@ -28,7 +28,7 @@ namespace Microsoft.Graph /// public class DeltaResponseHandler : IResponseHandler where T : IParsable, new() { - private readonly IAsyncParseNodeFactory parseNodeFactory; + private readonly IParseNodeFactory parseNodeFactory; /// /// Constructs a new . @@ -36,7 +36,7 @@ namespace Microsoft.Graph /// The to use for response handling public DeltaResponseHandler(IParseNodeFactory parseNodeFactory = null) { - this.parseNodeFactory = parseNodeFactory as IAsyncParseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; + this.parseNodeFactory = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; } /// diff --git a/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs b/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs index d94b157cc..c1445ac52 100644 --- a/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs +++ b/src/Microsoft.Graph.Core/Requests/GraphClientFactory.cs @@ -261,8 +261,6 @@ internal static HttpMessageHandler GetNativePlatformHttpHandler(IWebProxy proxy } #if IOS || MACCATALYST return new NSUrlSessionHandler { AllowAutoRedirect = false }; -#elif MACOS - return new Foundation.NSUrlSessionHandler { AllowAutoRedirect = false }; #elif ANDROID return new Xamarin.Android.Net.AndroidMessageHandler { Proxy = proxy, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.All }; #elif NETFRAMEWORK diff --git a/src/Microsoft.Graph.Core/Requests/ResponseHandler.cs b/src/Microsoft.Graph.Core/Requests/ResponseHandler.cs index 3979c35af..44675b1a6 100644 --- a/src/Microsoft.Graph.Core/Requests/ResponseHandler.cs +++ b/src/Microsoft.Graph.Core/Requests/ResponseHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.Graph /// public class ResponseHandler : IResponseHandler where T : IParsable, new() { - private readonly IAsyncParseNodeFactory _jsonParseNodeFactory; + private readonly IParseNodeFactory _jsonParseNodeFactory; /// /// Constructs a new . @@ -24,7 +24,7 @@ namespace Microsoft.Graph /// The to use for response handling public ResponseHandler(IParseNodeFactory parseNodeFactory = null) { - _jsonParseNodeFactory = parseNodeFactory as IAsyncParseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; ; + _jsonParseNodeFactory = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; } /// diff --git a/src/Microsoft.Graph.Core/Requests/Upload/UploadResponseHandler.cs b/src/Microsoft.Graph.Core/Requests/Upload/UploadResponseHandler.cs index a2a2fbd46..142788204 100644 --- a/src/Microsoft.Graph.Core/Requests/Upload/UploadResponseHandler.cs +++ b/src/Microsoft.Graph.Core/Requests/Upload/UploadResponseHandler.cs @@ -17,7 +17,7 @@ namespace Microsoft.Graph /// internal class UploadResponseHandler { - private readonly IAsyncParseNodeFactory _parseNodeFactory; + private readonly IParseNodeFactory _parseNodeFactory; /// /// Constructs a new . @@ -25,7 +25,7 @@ internal class UploadResponseHandler /// The to use for response handling public UploadResponseHandler(IParseNodeFactory parseNodeFactory = null) { - _parseNodeFactory = parseNodeFactory as IAsyncParseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; + _parseNodeFactory = parseNodeFactory ?? ParseNodeFactoryRegistry.DefaultInstance; } /// diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Test/Helpers/ReadOnlySubStreamTests.cs b/tests/Microsoft.Graph.DotnetCore.Core.Test/Helpers/ReadOnlySubStreamTests.cs index 7c8737869..b7b59511e 100644 --- a/tests/Microsoft.Graph.DotnetCore.Core.Test/Helpers/ReadOnlySubStreamTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Core.Test/Helpers/ReadOnlySubStreamTests.cs @@ -78,7 +78,7 @@ public void SubstreamsAreReadableFromDifferentPositionsTimes() // reset stream to middle and read again substream.Seek(5, SeekOrigin.Begin); readBytes = streamReader.ReadToEnd(); - Assert.Equal(segment[5..], readBytes); + Assert.Equal(segment.Substring(5), readBytes); // reset stream and read again substream.Position = 0; diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Test/Microsoft.Graph.DotnetCore.Core.Test.csproj b/tests/Microsoft.Graph.DotnetCore.Core.Test/Microsoft.Graph.DotnetCore.Core.Test.csproj index 8c4f611e9..e7d48382c 100644 --- a/tests/Microsoft.Graph.DotnetCore.Core.Test/Microsoft.Graph.DotnetCore.Core.Test.csproj +++ b/tests/Microsoft.Graph.DotnetCore.Core.Test/Microsoft.Graph.DotnetCore.Core.Test.csproj @@ -1,6 +1,6 @@ - net6.0 + net462;net8.0;net10.0 false false false @@ -18,23 +18,23 @@ all - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentStepsTests.cs b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentStepsTests.cs index 070d5fdad..02d697374 100644 --- a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentStepsTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentStepsTests.cs @@ -15,7 +15,7 @@ public BatchRequestContentStepsTests() _steps = new BatchRequestContentSteps(); _steps.Add("1", new BatchRequestStep("1", new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/v1.0/me"))); _steps["2"] = new BatchRequestStep("2", new HttpRequestMessage(HttpMethod.Post, "https://graph.microsoft.com/v1.0/me")); - _steps["uuid-123"] = new BatchRequestStep("uuid-123", new HttpRequestMessage(HttpMethod.Patch, "https://graph.microsoft.com/v1.0/me")); + _steps["uuid-123"] = new BatchRequestStep("uuid-123", new HttpRequestMessage(new HttpMethod("PATCH"), "https://graph.microsoft.com/v1.0/me")); } [Fact] diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentTests.cs b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentTests.cs index 4ce0801fc..b68c33978 100644 --- a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentTests.cs @@ -601,7 +601,11 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestWithHead Assert.True(batchRequestContent.BatchRequestSteps[batchRequestStepId].Request.Content.Headers.Any()); // we do this to get a version of the json payload that is indented +#if NETFRAMEWORK + using var requestStream = await batchRequestContent.GetBatchRequestContentAsync(); +#else await using var requestStream = await batchRequestContent.GetBatchRequestContentAsync(); +#endif using var jsonDocument = await JsonDocument.ParseAsync(requestStream); string requestContentString = JsonSerializer.Serialize(jsonDocument.RootElement, new JsonSerializerOptions() { WriteIndented = true }); diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs index d48de2414..d4d9c7f12 100644 --- a/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs @@ -273,7 +273,11 @@ public void CreateClient_WithInnerHandlerReference() // Creation should ignore the InnerHandler on RetryHandler HttpClient client = GraphClientFactory.Create(handlers: handlers); Assert.NotNull(client); +#if NETFRAMEWORK + Assert.IsType(handlers[0].InnerHandler); +#else Assert.IsType(handlers[0].InnerHandler); +#endif } [Fact] diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Test/Tasks/LargeFileUploadTaskTests.cs b/tests/Microsoft.Graph.DotnetCore.Core.Test/Tasks/LargeFileUploadTaskTests.cs index c40e5a9a6..e27f6583d 100644 --- a/tests/Microsoft.Graph.DotnetCore.Core.Test/Tasks/LargeFileUploadTaskTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Core.Test/Tasks/LargeFileUploadTaskTests.cs @@ -210,7 +210,7 @@ public void BreaksDownStreamIntoRangesCorrectly() } //The last slice is a bit smaller than the rest - var lastUploadSlice = uploadSlices[^1]; + var lastUploadSlice = uploadSlices[uploadSlices.Length - 1]; Assert.Equal(stream.Length - 1, lastUploadSlice.RangeEnd); Assert.Equal(stream.Length % maxSliceSize, lastUploadSlice.RangeLength); //verify the last slice is the right size } @@ -250,15 +250,18 @@ public async Task HandlesCancellationTokenAsync() // Create cancelled token var cancellationTokenSource = new CancellationTokenSource(); CancellationToken cancellationToken = cancellationTokenSource.Token; +#if NET8_0_OR_GREATER + await cancellationTokenSource.CancelAsync(); +#else cancellationTokenSource.Cancel(); +#endif // Create task IBaseClient baseClient = new BaseClient(new BaseGraphRequestAdapter(new AnonymousAuthenticationProvider(), httpClient: GraphClientFactory.Create(finalHandler: testHttpMessageHandler))); var fileUploadTask = new LargeFileUploadTask(uploadSession, stream, maxSliceSize, baseClient.RequestAdapter); // Assert that the task is cancellable - var cancellationException = await Assert.ThrowsAsync(() => fileUploadTask.UploadAsync(cancellationToken: cancellationToken)); - Assert.Contains("A task was canceled", cancellationException.Message); + var cancellationException = await Assert.ThrowsAnyAsync(() => fileUploadTask.UploadAsync(cancellationToken: cancellationToken)); } } } diff --git a/tests/Microsoft.Graph.DotnetCore.Core.Trimming/Microsoft.Graph.DotnetCore.Core.Trimming.csproj b/tests/Microsoft.Graph.DotnetCore.Core.Trimming/Microsoft.Graph.DotnetCore.Core.Trimming.csproj index 3bfa7a49d..6bc8a408e 100644 --- a/tests/Microsoft.Graph.DotnetCore.Core.Trimming/Microsoft.Graph.DotnetCore.Core.Trimming.csproj +++ b/tests/Microsoft.Graph.DotnetCore.Core.Trimming/Microsoft.Graph.DotnetCore.Core.Trimming.csproj @@ -1,7 +1,7 @@ Exe - net9.0 + net10.0 enable enable true