-
Notifications
You must be signed in to change notification settings - Fork 200
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
Fully immutable spancontexts #8245
Conversation
47c1cbc
to
665ca58
Compare
|
||
public Func<string, IEnumerable<Syntax.InternalSyntax.SyntaxToken>> Tokenizer { get; set; } | ||
|
||
public static SpanEditHandler CreateDefault() |
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.
When refactoring, I found the implicit AcceptedCharactersInternal
values confusing, so I removed this overload.
|
||
public string AutoCompleteString { get; set; } | ||
public string AutoCompleteString => _autoCompleteStringAccessor.CanAcceptCloseBrace ? "}" : null; |
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.
This is the only place where we were using the mutation capabilities of contexts, and it was really just delayed initialization. I've replaced it with an accessor that verifies only one set occurs, and verifies that the set occurred before access.
7555723
to
7ba0da4
Compare
@dotnet/razor-compiler for review please. |
|
||
public string AssemblyName { get; set; } | ||
public string AssemblyName { get; } | ||
|
||
public List<RazorDiagnostic> Diagnostics { get; } |
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.
Is the expectation that this becomes ImmutableArray<ReportDiagnostic>
in the future?
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.
My expectation is that this gets removed entirely at some point 🙂.
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenEditHandler.cs
Outdated
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Legacy/SpanEditHandlerBuilder.cs
Outdated
Show resolved
Hide resolved
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.
LGTM
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Legacy/SpanEditHandlerBuilder.cs
Show resolved
Hide resolved
src/Compiler/Microsoft.AspNetCore.Razor.Language/src/Legacy/SpanEditHandlerBuilder.cs
Show resolved
Hide resolved
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.
LGTM
a591e1d
to
b6d0d0a
Compare
...enerator.Tooling.Internal/Microsoft.AspNetCore.Razor.SourceGenerator.Tooling.Internal.csproj
Outdated
Show resolved
Hide resolved
Only one context needs a bit of delayed initialization, the AutoComplete context, as it needs to know whether or not to accept a closing brace during partial reparsing. Aside from this single instance, all other contexts were used completely immutably, and now reflect this.
b6d0d0a
to
c1c17fc
Compare
Makes all span contexts fully immutable, and converts to a builder pattern for creating them during parsing.