@@ -77,9 +77,8 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
7777 return ;
7878 }
7979
80- var methodAndUrlComparer = new MethodAndUrlComparer ( ) ;
81- var delegatedEndpoints = new List < ( string method , string url ) > ( ) ;
82- var applicationEndpoints = new List < ( string method , string url ) > ( ) ;
80+ var delegatedEndpoints = new List < MethodAndUrl > ( ) ;
81+ var applicationEndpoints = new List < MethodAndUrl > ( ) ;
8382
8483 // scope for delegated permissions
8584 IEnumerable < string > scopesToEvaluate = [ ] ;
@@ -95,20 +94,20 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
9594
9695 var methodAndUrlString = request . Message ;
9796 var methodAndUrl = MethodAndUrlUtils . ToMethodAndUrl ( methodAndUrlString ) ;
98- if ( methodAndUrl . method . Equals ( "OPTIONS" , StringComparison . OrdinalIgnoreCase ) )
97+ if ( methodAndUrl . Method . Equals ( "OPTIONS" , StringComparison . OrdinalIgnoreCase ) )
9998 {
10099 continue ;
101100 }
102101
103- if ( ! ProxyUtils . MatchesUrlToWatch ( UrlsToWatch , methodAndUrl . url ) )
102+ if ( ! ProxyUtils . MatchesUrlToWatch ( UrlsToWatch , methodAndUrl . Url ) )
104103 {
105- Logger . LogDebug ( "URL not matched: {Url}" , methodAndUrl . url ) ;
104+ Logger . LogDebug ( "URL not matched: {Url}" , methodAndUrl . Url ) ;
106105 continue ;
107106 }
108107
109- var requestsFromBatch = Array . Empty < ( string method , string url ) > ( ) ;
108+ var requestsFromBatch = Array . Empty < MethodAndUrl > ( ) ;
110109
111- var uri = new Uri ( methodAndUrl . url ) ;
110+ var uri = new Uri ( methodAndUrl . Url ) ;
112111 if ( ! ProxyUtils . IsGraphUrl ( uri ) )
113112 {
114113 continue ;
@@ -121,7 +120,7 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
121120 }
122121 else
123122 {
124- methodAndUrl = ( methodAndUrl . method , GetTokenizedUrl ( methodAndUrl . url ) ) ;
123+ methodAndUrl = new ( methodAndUrl . Method , GetTokenizedUrl ( methodAndUrl . Url ) ) ;
125124 }
126125
127126 var ( type , permissions ) = GetPermissionsAndType ( request ) ;
@@ -162,8 +161,8 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
162161 }
163162
164163 // Remove duplicates
165- delegatedEndpoints = [ .. delegatedEndpoints . Distinct ( methodAndUrlComparer ) ] ;
166- applicationEndpoints = [ .. applicationEndpoints . Distinct ( methodAndUrlComparer ) ] ;
164+ delegatedEndpoints = [ .. delegatedEndpoints . Distinct ( ) ] ;
165+ applicationEndpoints = [ .. applicationEndpoints . Distinct ( ) ] ;
167166
168167 if ( delegatedEndpoints . Count == 0 && applicationEndpoints . Count == 0 )
169168 {
@@ -187,7 +186,7 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
187186 var delegatedPermissionsInfo = new GraphMinimalPermissionsInfo ( ) ;
188187 report . DelegatedPermissions = delegatedPermissionsInfo ;
189188
190- Logger . LogInformation ( "Evaluating delegated permissions for: {Endpoints}" , string . Join ( ", " , delegatedEndpoints . Select ( e => $ "{ e . method } { e . url } ") ) ) ;
189+ Logger . LogInformation ( "Evaluating delegated permissions for: {Endpoints}" , string . Join ( ", " , delegatedEndpoints . Select ( e => $ "{ e . Method } { e . Url } ") ) ) ;
191190
192191 await EvaluateMinimalScopesAsync ( delegatedEndpoints , scopesToEvaluate , GraphPermissionsType . Delegated , delegatedPermissionsInfo , cancellationToken ) ;
193192 }
@@ -197,7 +196,7 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
197196 var applicationPermissionsInfo = new GraphMinimalPermissionsInfo ( ) ;
198197 report . ApplicationPermissions = applicationPermissionsInfo ;
199198
200- Logger . LogInformation ( "Evaluating application permissions for: {Endpoints}" , string . Join ( ", " , applicationEndpoints . Select ( e => $ "{ e . method } { e . url } ") ) ) ;
199+ Logger . LogInformation ( "Evaluating application permissions for: {Endpoints}" , string . Join ( ", " , applicationEndpoints . Select ( e => $ "{ e . Method } { e . Url } ") ) ) ;
201200
202201 await EvaluateMinimalScopesAsync ( applicationEndpoints , rolesToEvaluate , GraphPermissionsType . Application , applicationPermissionsInfo , cancellationToken ) ;
203202 }
@@ -217,7 +216,7 @@ private void InitializePermissionsToExclude()
217216 }
218217
219218 private async Task EvaluateMinimalScopesAsync (
220- IEnumerable < ( string method , string url ) > endpoints ,
219+ IEnumerable < MethodAndUrl > endpoints ,
221220 IEnumerable < string > permissionsFromAccessToken ,
222221 GraphPermissionsType scopeType ,
223222 GraphMinimalPermissionsInfo permissionsInfo ,
@@ -228,12 +227,12 @@ private async Task EvaluateMinimalScopesAsync(
228227 throw new InvalidOperationException ( "GraphUtils is not initialized. Make sure to call InitializeAsync first." ) ;
229228 }
230229
231- var payload = endpoints . Select ( e => new GraphRequestInfo { Method = e . method , Url = e . url } ) ;
230+ var payload = endpoints . Select ( e => new GraphRequestInfo { Method = e . Method , Url = e . Url } ) ;
232231
233232 permissionsInfo . Operations = [ .. endpoints . Select ( e => new GraphMinimalPermissionsOperationInfo
234233 {
235- Method = e . method ,
236- Endpoint = e . url
234+ Method = e . Method ,
235+ Endpoint = e . Url
237236 } ) ] ;
238237 permissionsInfo . PermissionsFromTheToken = permissionsFromAccessToken ;
239238
@@ -289,9 +288,9 @@ private async Task EvaluateMinimalScopesAsync(
289288 }
290289 }
291290
292- private static ( string method , string url ) [ ] GetRequestsFromBatch ( string batchBody , string graphVersion , string graphHostName )
291+ private static MethodAndUrl [ ] GetRequestsFromBatch ( string batchBody , string graphVersion , string graphHostName )
293292 {
294- var requests = new List < ( string method , string url ) > ( ) ;
293+ var requests = new List < MethodAndUrl > ( ) ;
295294
296295 if ( string . IsNullOrEmpty ( batchBody ) )
297296 {
@@ -313,7 +312,8 @@ private static (string method, string url)[] GetRequestsFromBatch(string batchBo
313312 var method = request . Method ;
314313 var url = request . Url ;
315314 var absoluteUrl = $ "https://{ graphHostName } /{ graphVersion } { url } ";
316- requests . Add ( ( method , GetTokenizedUrl ( absoluteUrl ) ) ) ;
315+ MethodAndUrl methodAndUrl = new ( Method : method , Url : GetTokenizedUrl ( absoluteUrl ) ) ;
316+ requests . Add ( methodAndUrl ) ;
317317 }
318318 catch { }
319319 }
0 commit comments