Skip to content

Commit 2d50cc3

Browse files
m-nashtg-msft
andauthored
Fix some perf issues in SCM SourceGeneration (Azure#50326)
* Fix some perf issues in SCM SourceGeneration * Fix WebJobs Storage listener mock failure from latest Storage release that made AccountName virtual --------- Co-authored-by: tg-msft <[email protected]>
1 parent 79ae0a2 commit 2d50cc3

File tree

5 files changed

+152
-189
lines changed

5 files changed

+152
-189
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.CodeAnalysis;
5+
6+
namespace System.ClientModel.SourceGeneration
7+
{
8+
internal static class IncrementalValuesProviderExtensions
9+
{
10+
public static IncrementalValuesProvider<TResult> SelectWhen<TInput, TResult>(
11+
this IncrementalValuesProvider<TInput> input,
12+
IncrementalValueProvider<bool> condition,
13+
Func<TInput, TResult?> selector)
14+
where TResult : class
15+
{
16+
return input
17+
.Combine(condition)
18+
.Where(static tuple => tuple.Right)
19+
.Select((tuple, _) => selector(tuple.Left))
20+
.Where(static result => result is not null)
21+
.Select(static (result, _) => result!);
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)