Uh oh!
There was an error while loading. Please reload this page.
Correct formatting of config binder generator - #83614
Conversation
ghost
commented
Mar 17, 2023
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsFixes: #83538
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
94c973a to
fc5263eCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
I wonder why we need this class at all. The Regex source generator just uses an IntendedTextWriter:
runtime/src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.cs
Lines 120 to 122 in 967250c
Why can't we follow the same pattern here?
There was a problem hiding this comment.
Sure I'll look into switching to this.
There was a problem hiding this comment.
One issue I find with that class is that it doesn't intercept line breaks in user strings to introduce additional indentation. So it actual breaks once you try to use multi-line string literals:
varsw=newStringWriter();varwriter=newIndentedTextWriter(sw);writer.WriteLine("{");writer.Indent++;writer.WriteLine(""" var x = 42; return x.ToString(); """);writer.Indent--;writer.WriteLine("}");Console.WriteLine(sw.ToString());Prints
{varx=42;returnx.ToString();}There was a problem hiding this comment.
It looks like the Regex source generator doesn't use multi-line strings:
When using a CodeWriter (which derives from IndentedTextWriter) in the RequestDelegateGenerator, it looks like we don't use multi-line strings either:
However, we do use multi-line strings in the RequestDelegateGenerator when just appending strings together
cc @captainsafia@stephentoub - thoughts on how to generate code here?
There was a problem hiding this comment.
Maybe, but I'd say we should use a component that does not prohibit use of multi-line strings in future iterations. I find that it's easier to write and understand in practice:
Perhaps having a bespoke class in the Common folder that does support it in all the right ways this might be appropriate.
There was a problem hiding this comment.
I think that being able to write both single and multi-line strings conveniently is beneficial and we should permit source generators to do both. Multi-line strings make the code more readable while single lines help with source composition/nesting.
There was a problem hiding this comment.
We generally use multiline strings in the RequestDelegateGenerator if the code emitted doesn't depend on any conditions and doesn't have complex indentation requirements. As @eiriktsarpalis mentioned, multi-line strings are a lot harder to read then invocations to the CodeWriter.
8d72491 to
af4468fCompareUh oh!
There was an error while loading. Please reload this page.
142d0c3 to
9f8adbdCompare
Fixes: #83538
General emitted structure now follows feedback from initial PR, observable by inspecting baseline files: