[CSharp] Fix for #3510 -- accept grammars with either "->Channel(HIDDEN)" or "->channel(HIDDEN)" for CSharp #3547
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR fix?
Discussion
The problem here revolves around an undocumented syntax in Antlr lexers. Use of "Channel(HIDDEN)" is accepted (in addition to the documented use of "channel(HIDDEN)") in a lexer grammar, but is outputted to the generated lexer as "_channel = HIDDEN". Unfortunately, this cannot work because the Antlr CSharp runtime sets the accessibility of the various fields ("_channel", "_type", "_mode") to private, and provides instead get and set properties. The generated code already uses the public method
PushMode()
, and I don't want to change the visibility of the runtime for_channel
, this change uses property set instead.The change is essentially to three lines in the .stg file for CSharp. I've added a test to the CSharp runtime that has a lexer use both "channel(HIDDEN)" and "Channel(HIDDEN)".
Why is this PR important?
In my opinion, this PR is not that important when compared to PRs to fix #3441, #3443, but I would include it in a long list of minor problems. There is no documentation describing "Channel()"; only "channel()" is documented. It occurs in grammars-v4/rego/RegoLexer.g4, which hasn't been targeted for CSharp only until recently.