-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an experimental API for testing incremental steps. #1094
base: main
Are you sure you want to change the base?
Changes from 4 commits
976e90b
bd6388b
cf6165f
f5c08c3
55446d6
7429c65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using System.Threading; | ||
|
||
namespace Microsoft.CodeAnalysis.Testing | ||
{ | ||
public class IncrementalGeneratorExpectedState | ||
{ | ||
internal Dictionary<string, List<IncrementalGeneratorExpectedStepState>> ExpectedStepStates { get; } = new Dictionary<string, List<IncrementalGeneratorExpectedStepState>>(); | ||
|
||
public List<IncrementalGeneratorExpectedStepState> this[string stepName] | ||
{ | ||
get | ||
{ | ||
return ExpectedStepStates.GetOrAdd(stepName, () => new List<IncrementalGeneratorExpectedStepState>()); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.CodeAnalysis.Testing | ||
{ | ||
public class IncrementalGeneratorExpectedStepState | ||
{ | ||
public List<IncrementalStepExpectedRunReason> InputRunReasons { get; } = new List<IncrementalStepExpectedRunReason>(); | ||
|
||
public List<IncrementalStepExpectedRunReason> OutputRunReasons { get; } = new List<IncrementalStepExpectedRunReason>(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Microsoft.CodeAnalysis.Testing | ||
{ | ||
/// <summary> | ||
/// The state of the output of a given executed incremental source generator step. | ||
/// </summary> | ||
public enum IncrementalStepExpectedRunReason | ||
{ | ||
/// <summary> | ||
/// The output of this step is a new output produced from a new input. | ||
/// </summary> | ||
New, | ||
|
||
/// <summary> | ||
/// The input to this step was modified from a previous run, and it produced a different value than the previous run. | ||
/// </summary> | ||
Modified, | ||
|
||
/// <summary> | ||
/// The input to this step was modified from a previous run, but it produced an equal value to the previous run. | ||
/// </summary> | ||
Unchanged, | ||
|
||
/// <summary> | ||
/// The output of this step was pulled from this step's cache since the inputs was unchanged from the previous run. | ||
/// </summary> | ||
Cached, | ||
|
||
/// <summary> | ||
/// The input that this output is generated from was removed from the input step's outputs, so this value will be removed from the output step results. | ||
/// </summary> | ||
Removed, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Microsoft.CodeAnalysis.Testing; | ||
|
||
|
@@ -27,5 +28,19 @@ protected override CompilationOptions CreateCompilationOptions() | |
|
||
protected override ParseOptions CreateParseOptions() | ||
=> new CSharpParseOptions(DefaultLanguageVersion, DocumentationMode.Diagnose); | ||
|
||
public IncrementalGeneratorExpectedState IncrementalGeneratorState | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 I think we can remove this in favor of changing the type of
|
||
{ | ||
get | ||
{ | ||
if (!IncrementalGeneratorStates.TryGetValue(typeof(TSourceGenerator), out var value)) | ||
{ | ||
value = new IncrementalGeneratorExpectedState(); | ||
IncrementalGeneratorStates.Add(typeof(TSourceGenerator), value); | ||
} | ||
|
||
return value; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 I would prefer to remove this dependency before merge, but that's further down the line. I'm mostly focusing on the API itself right now.