1

I'm trying to write a C# snippet with this content:

...
<References>
    <Reference><Assembly>Microsoft.VisualBasic.dll</Assembly></Reference>
</References>

<Imports>
    <Import><Namespace>Microsoft.VisualBasic</Namespace></Import>
    <Import><Namespace>System.Text</Namespace></Import>
    <Import><Namespace>System.Xml</Namespace></Import>
</Imports>
...

As explained in the MSDN docs, im following the good structure:

Create a New Snippet with Imports and References - MSDN

I made two versions of the snippet, one for VB.Net and the other for CSharp which only differs on the code language declaration and the the code block, the rest of the snippet is the same.

Well, the VB version works perfect, it adds the Imports statements that I declared and the assembly reference, but the C# version does not add any using statement neither the assembly reference tat I declared in the snippet.

Why? How to fix it?.

UPDATE

I found the same issue from other person in StackOverflow, which never has been resolved, the solutions given are are unproductive:

There's a way to create a code snippet with automatically create a using reference?

Community
  • 1
  • 1
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417

1 Answers1

0

From the page you linked:

If you create a Visual Basic code snippet, you have the ability to specify the necessary references and Imports statements required for your code to run.

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
MatteoSp
  • 2,940
  • 5
  • 28
  • 36
  • 1
    `Why do you expect this should work in C#?` 'Cause Is what every user should expect when purchasing a Microsoft product,it is ridiculous that only one of the supported languages for this IDE appears to support the `` feature when writting an snippet,really there isn't any compatibility?,then why Microsoft made the snippets feature for C# if it cannot integrate namespaces and need to manage ugly literals while in VB.Net is really as how it should be?. The question better should be `Why the enduser should expect this will don't work for both VB.Net and C#?` (since its a global feature) – ElektroStudios May 05 '15 at 11:35
  • 1
    You should not consider .Net as unique huge product. It's something totally different, is a complex, highly componentized system built up by many many different teams. And the snippet management it's not a global feature (such a feature does not even exist), it's an IDE feature, built with the support of the compilers (which are language specific). With this in mind, should be clear that every feature, or even every declination of a feature may be supported or not for huge variety of reasons. – MatteoSp May 05 '15 at 12:30
  • 1
    See the Hans Passant's answer to this question: http://stackoverflow.com/questions/4473600/why-code-snippet-in-vb-is-more-featured-than-in-c – MatteoSp May 05 '15 at 12:39
  • "Why do you expect this should work in C#?" Wow... so much arrogance. No wonder people are turned away from stackoverflow these days. https://stackoverflow.blog/2018/04/26/stack-overflow-isnt-very-welcoming-its-time-for-that-to-change/ – Brian Webster May 04 '18 at 03:04