-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Quote Jason's comment at https://github.com/PowerShell/PowerShell/pull/6434/files/5b5be3122971552d2ce208858ac84868954b841c#r175933192
I'd suggest removing my ugly hack of using LINQ expression trees in SaveError and related helper methods, and replace with nameof(ParserStrings.MissingEndCurlyBrace).
When that code was written, nameof was not in C#, so the ugly and inefficient code was used because:
- It ensured no typos in the
FullyQualifiedErrorId. - It was easy to search for all references to an error message via the property.
- Performance was not deemed important because they were errors.
Performance might matter more than I originally assumed given editor scenarios - and given the nameof language feature, it's reasonable (but annoying and a little verbose) to change error reporting to look more like:
ReportIncompleteInput(lCurly.Extent, rCurly.Extent,
ParserStrings.MissingEndCurlyBrace, nameof(ParserStrings.MissingEndCurlyBrace));In other words, pass the error text and the error id.
Alternatively you could just pass the error id and use reflection of some sort to load the error string, but that would not be good for performance.