Skip to content

Commit df67207

Browse files
authored
Merge pull request #638 from microsoftgraph/dev
Release 3.0.5
2 parents e208ea2 + 05b08c3 commit df67207

File tree

7 files changed

+81
-19
lines changed

7 files changed

+81
-19
lines changed

pipelines/previewBuild.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ steps:
4343
inputs:
4444
version: 6.x
4545

46-
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
46+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
4747
displayName: 'Run CredScan'
4848
inputs:
49+
toolMajorVersion: 'V2'
50+
scanFolder: '$(Build.SourcesDirectory)'
4951
debugMode: false
5052

5153
- task: PowerShell@2
@@ -95,13 +97,14 @@ steps:
9597
projects: '$(Build.SourcesDirectory)\src\Microsoft.Graph.Core\Microsoft.Graph.Core.csproj'
9698
arguments: '-c Release --no-incremental'
9799

98-
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
100+
- task: EsrpCodeSigning@2
99101
displayName: 'ESRP DLL Strong Name (Microsoft.Graph.Core)'
100102
inputs:
101103
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
102104
FolderPath: src/Microsoft.Graph.Core/bin/release
103-
Pattern: Microsoft.Graph.Core.dll
105+
Pattern: '**\*Microsoft.Graph.Core.dll'
104106
signConfigType: inlineSignParams
107+
UseMinimatch: true
105108
inlineOperation: |
106109
[
107110
{
@@ -121,12 +124,13 @@ steps:
121124
]
122125
SessionTimeout: 20
123126

124-
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
127+
- task: EsrpCodeSigning@2
125128
displayName: 'ESRP DLL CodeSigning (Microsoft.Graph.Core)'
126129
inputs:
127130
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
128131
FolderPath: src/Microsoft.Graph.Core/bin/release
129-
Pattern: Microsoft.Graph.Core.dll
132+
Pattern: '**\*Microsoft.Graph.Core.dll'
133+
UseMinimatch: true
130134
signConfigType: inlineSignParams
131135
inlineOperation: |
132136
[
@@ -173,11 +177,12 @@ steps:
173177
dotnet pack $env:BUILD_SOURCESDIRECTORY/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --no-build --output $env:BUILD_ARTIFACTSTAGINGDIRECTORY --configuration Release
174178
displayName: dotnet pack
175179

176-
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
180+
- task: EsrpCodeSigning@2
177181
displayName: 'ESRP NuGet CodeSigning'
178182
inputs:
179183
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
180184
FolderPath: '$(Build.ArtifactStagingDirectory)'
185+
UseMinimatch: true
181186
Pattern: '*nupkg'
182187
signConfigType: inlineSignParams
183188
inlineOperation: |

pipelines/productionBuild.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ steps:
4242
inputs:
4343
version: 6.x
4444

45-
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
45+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
4646
displayName: 'Run CredScan'
4747
inputs:
48+
toolMajorVersion: 'V2'
49+
scanFolder: '$(Build.SourcesDirectory)'
4850
debugMode: false
4951

5052
- task: PowerShell@2
@@ -86,12 +88,13 @@ steps:
8688
projects: '$(Build.SourcesDirectory)\src\Microsoft.Graph.Core\Microsoft.Graph.Core.csproj'
8789
arguments: '-c Release --no-incremental'
8890

89-
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
91+
- task: EsrpCodeSigning@2
9092
displayName: 'ESRP DLL Strong Name (Microsoft.Graph.Core) (AKV)'
9193
inputs:
9294
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
9395
FolderPath: src/Microsoft.Graph.Core/bin/release
94-
Pattern: Microsoft.Graph.Core.dll
96+
Pattern: '**\*Microsoft.Graph.Core.dll'
97+
UseMinimatch: true
9598
signConfigType: inlineSignParams
9699
inlineOperation: |
97100
[
@@ -112,12 +115,13 @@ steps:
112115
]
113116
SessionTimeout: 20
114117

115-
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
118+
- task: EsrpCodeSigning@2
116119
displayName: 'ESRP DLL CodeSigning (Microsoft.Graph.Core)'
117120
inputs:
118121
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
119122
FolderPath: src/Microsoft.Graph.Core/bin/release
120-
Pattern: Microsoft.Graph.Core.dll
123+
Pattern: '**\*Microsoft.Graph.Core.dll'
124+
UseMinimatch: true
121125
signConfigType: inlineSignParams
122126
inlineOperation: |
123127
[
@@ -164,12 +168,13 @@ steps:
164168
dotnet pack $env:BUILD_SOURCESDIRECTORY/src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --no-build --output $env:BUILD_ARTIFACTSTAGINGDIRECTORY --configuration Release
165169
displayName: dotnet pack
166170

167-
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
171+
- task: EsrpCodeSigning@2
168172
displayName: 'ESRP NuGet CodeSigning'
169173
inputs:
170174
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
171175
FolderPath: '$(Build.ArtifactStagingDirectory)'
172176
Pattern: '*.nupkg'
177+
UseMinimatch: true
173178
signConfigType: inlineSignParams
174179
inlineOperation: |
175180
[

src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
<DelaySign>false</DelaySign>
2121
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
2222
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
23-
<VersionPrefix>3.0.4</VersionPrefix>
23+
<VersionPrefix>3.0.5</VersionPrefix>
2424
<VersionSuffix></VersionSuffix>
2525
<PackageReleaseNotes>
26-
- Updates kiota abstraction library dependencies to for generation updates to reduce code size
26+
- Adds support from create a new batch request from failed requests(https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/pull/636)
27+
- Updates batchReqeust builders to allow passing of error mappings from service libraries.
2728
</PackageReleaseNotes>
2829
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2930
<EmbedUntrackedSources>true</EmbedUntrackedSources>

src/Microsoft.Graph.Core/Requests/BatchRequestBuilder.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
namespace Microsoft.Graph.Core.Requests
66
{
77
using Microsoft.Kiota.Abstractions;
8+
using Microsoft.Kiota.Abstractions.Serialization;
89
using System;
910
using System.Net.Http;
1011
using System.Threading;
1112
using System.Threading.Tasks;
13+
using System.Collections.Generic;
1214

1315
/// <summary>
1416
/// The type BatchRequestBuilder
@@ -41,31 +43,33 @@ public BatchRequestBuilder(IRequestAdapter requestAdapter)
4143
/// </summary>
4244
/// <param name="batchRequestContent">The <see cref="BatchRequestContent"/> for the request</param>
4345
/// <param name="cancellationToken"><see cref="CancellationToken"/> to use for cancelling requests</param>
46+
/// <param name="errorMappings">The error mappings to use for handling error responses</param>
4447
/// <returns></returns>
45-
public async Task<BatchResponseContent> PostAsync(BatchRequestContent batchRequestContent, CancellationToken cancellationToken = default)
48+
public async Task<BatchResponseContent> PostAsync(BatchRequestContent batchRequestContent, CancellationToken cancellationToken = default, Dictionary<string, ParsableFactory<IParsable>> errorMappings = null)
4649
{
4750
_ = batchRequestContent ?? throw new ArgumentNullException(nameof(batchRequestContent));
4851
var requestInfo = await ToPostRequestInformationAsync(batchRequestContent);
4952
var nativeResponseHandler = new NativeResponseHandler();
5053
requestInfo.SetResponseHandler(nativeResponseHandler);
5154
await this.RequestAdapter.SendNoContentAsync(requestInfo, cancellationToken:cancellationToken);
52-
return new BatchResponseContent(nativeResponseHandler.Value as HttpResponseMessage);
55+
return new BatchResponseContent(nativeResponseHandler.Value as HttpResponseMessage, errorMappings);
5356
}
5457

5558
/// <summary>
5659
/// Sends out the <see cref="BatchRequestContentCollection"/> using the POST method
5760
/// </summary>
5861
/// <param name="batchRequestContentCollection">The <see cref="BatchRequestContentCollection"/> for the request</param>
5962
/// <param name="cancellationToken"><see cref="CancellationToken"/> to use for cancelling requests</param>
63+
/// <param name="errorMappings">The error mappings to use for handling error responses</param>
6064
/// <returns></returns>
61-
public async Task<BatchResponseContentCollection> PostAsync(BatchRequestContentCollection batchRequestContentCollection, CancellationToken cancellationToken = default)
65+
public async Task<BatchResponseContentCollection> PostAsync(BatchRequestContentCollection batchRequestContentCollection, CancellationToken cancellationToken = default, Dictionary<string, ParsableFactory<IParsable>> errorMappings = null)
6266
{
6367
var collection = new BatchResponseContentCollection();
6468

6569
var requests = batchRequestContentCollection.GetBatchRequestsForExecution();
6670
foreach (var request in requests)
6771
{
68-
var response = await PostAsync(request, cancellationToken);
72+
var response = await PostAsync(request, cancellationToken, errorMappings);
6973
collection.AddResponse(request.BatchRequestSteps.Keys, response);
7074
}
7175

src/Microsoft.Graph.Core/Requests/Content/BatchRequestContent.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Microsoft.Graph
66
{
77
using Microsoft.Kiota.Abstractions;
8-
using Microsoft.Kiota.Http.HttpClientLibrary;
98
using System;
109
using System.Collections.Generic;
1110
using System.IO;
@@ -153,6 +152,25 @@ public bool RemoveBatchRequestStepWithId(string requestId)
153152
return isRemoved;
154153
}
155154

155+
/// <summary>
156+
/// Creates a new <see cref="BatchRequestContent"/> with all <see cref="BatchRequestStep"/> that failed.
157+
/// </summary>
158+
/// <param name="responseStatusCodes">A dictionary with response codes, get with batchResponseContent.GetResponsesStatusCodesAsync()</param>
159+
/// <returns>new <see cref="BatchRequestContent"/> with all failed requests.</returns>
160+
public BatchRequestContent NewBatchWithFailedRequests(Dictionary<string, HttpStatusCode> responseStatusCodes)
161+
{
162+
var request = new BatchRequestContent(this.RequestAdapter);
163+
foreach(var response in responseStatusCodes)
164+
{
165+
if (BatchRequestSteps.ContainsKey(response.Key) && !BatchResponseContent.IsSuccessStatusCode(response.Value)) {
166+
request.AddBatchRequestStep(BatchRequestSteps[response.Key]);
167+
}
168+
}
169+
return request;
170+
}
171+
172+
173+
156174
/// <summary>
157175
/// Get the content of the batchRequest in the form of a stream.
158176
/// It is the responsibility of the caller to dispose of the stream returned.

src/Microsoft.Graph.Core/Requests/Content/BatchRequestContentCollection.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
7+
using System.Net;
78
using System.Net.Http;
89
using System.Threading.Tasks;
910

@@ -141,5 +142,23 @@ public IReadOnlyDictionary<string, BatchRequestStep> BatchRequestSteps { get
141142
return currentRequest.BatchRequestSteps;
142143
}
143144
}
145+
146+
/// <summary>
147+
/// Creates a new <see cref="BatchRequestContentCollection"/> with all <see cref="BatchRequestStep"/> that failed.
148+
/// </summary>
149+
/// <param name="responseStatusCodes">A dictionary with response codes, get by executing batchResponseContentCollection.GetResponsesStatusCodesAsync()</param>
150+
/// <returns>new <see cref="BatchRequestContentCollection"/> with all failed requests.</returns>
151+
public BatchRequestContentCollection NewBatchWithFailedRequests(Dictionary<string, HttpStatusCode> responseStatusCodes)
152+
{
153+
var request = new BatchRequestContentCollection(this.baseClient, batchRequestLimit);
154+
var steps = this.BatchRequestSteps;
155+
foreach(var response in responseStatusCodes)
156+
{
157+
if (steps.ContainsKey(response.Key) && !BatchResponseContent.IsSuccessStatusCode(response.Value)) {
158+
request.AddBatchRequestStep(steps[response.Key].Request);
159+
}
160+
}
161+
return request;
162+
}
144163
}
145164
}

src/Microsoft.Graph.Core/Requests/Content/BatchResponseContent.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ public async Task<string> GetNextLinkAsync()
153153
return null;
154154
}
155155

156+
/// <summary>
157+
/// Checks is a <see cref="HttpStatusCode"/> can be marked as successful
158+
/// </summary>
159+
/// <param name="statusCode">A single <see cref="HttpStatusCode"/>.</param>
160+
/// <returns>Returns true if status code is between 200 and 300.</returns>
161+
public static bool IsSuccessStatusCode(HttpStatusCode statusCode)
162+
{
163+
return ((int)statusCode >= 200) && ((int)statusCode <= 299);
164+
}
165+
156166
/// <summary>
157167
/// Gets a <see cref="HttpResponseMessage"/> from <see cref="JsonElement"/> representing a batch response item.
158168
/// </summary>

0 commit comments

Comments
 (0)