Skip to content
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

Support #if SNIPPET in snippets #20391

Merged
merged 3 commits into from
Apr 15, 2021

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Apr 14, 2021

It's closer to C# syntax, can be used to verify that snippets still build after replacement and I can type it without having to consult the doc.

@pakrym
Copy link
Contributor Author

pakrym commented Apr 14, 2021

If we decide to do this I'll update all existing snippets and remove the commend syntax.

Copy link
Member

@christothes christothes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

eng/SnippetGenerator/DirectoryProcessor.cs Outdated Show resolved Hide resolved
@pakrym pakrym requested review from tg-msft and heaths April 14, 2021 17:16
Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. It should also help the occasional reformatting problems where VS wants to put /*@@*/ on it's own line and, if not caught, screws up the testable sample/snippet. At some point recently, too, VS seems to have stopped graying out ifdef'd out code and still provides IntelliSense, which helps writing syntactically correct snippet-only code.

@maririos
Copy link
Member

@tg-msft once opened this issue => #8539
1y 1/2 later it is getting done!!

@pakrym
Copy link
Contributor Author

pakrym commented Apr 14, 2021

Fixes: #8539

@pakrym
Copy link
Contributor Author

pakrym commented Apr 14, 2021

If we decide to do this I'll update all existing snippets and remove the commend syntax.

Maybe not, there are a LOT of them. I might ask service owners to clean up their samples.

@maririos
Copy link
Member

Maybe not, there are a LOT of them. I might ask service owners to clean up their samples.

Feel free to create issues per library and we can track the progress in the Eng Excellence epic.

Copy link
Member

@tg-msft tg-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. A couple of questions:

  • Will refactoring work in the #if SNIPPET branch?
  • Should we file a work item to schedule a weekly build with -d SNIPPET to make sure all the code that doesn't run still compiles?

@pakrym
Copy link
Contributor Author

pakrym commented Apr 15, 2021

Will refactoring work in the #if SNIPPET branch?

No, unfortunately, Roslyn treats the text in disabled branches as absent from the syntax/semantic tree.

Should we file a work item to schedule a weekly build with -d SNIPPET to make sure all the code that doesn't run still compiles?

Will do.

@pakrym
Copy link
Contributor Author

pakrym commented Apr 15, 2021

Filed: #20431 #20432

@pakrym pakrym enabled auto-merge (squash) April 15, 2021 16:57
@pakrym pakrym merged commit 4123f0f into Azure:master Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants