-
Notifications
You must be signed in to change notification settings - Fork 63
Add support for VB.NET #62
Comments
It will be some work to do this and the community is free to implement this looking over the C# implementation as a reference. I personally don't have VB.NET experience. |
@mjsabby Given that the logic in the individual analyzers is very much tied to the classes in // https://github.com/Microsoft/RoslynClrHeapAllocationAnalyzer/blob/master/ClrHeapAllocationsAnalyzer/DisplayClassAllocationAnalyzer.cs#L42
if (node is SimpleLambdaExpressionSyntax lambdaExpr)
{
...
}
if (node is ParenthesizedLambdaExpressionSyntax parenLambdaExpr)
{
...
} I don't suppose there is any benefit in extracting the common logic to a base class and having each language-specific analyzer inherit from the corresponding base class.
Moreover, this might not be possible, because there often isn't a one-to-one correspondence between syntax nodes: e.g. C# has Even the base class for all the analyzers cannot be used without modification for VB.NET, as it defines the Which now leads to the next question: once the VB.NET analyzer is in a separate project, should it be written in C# or VB.NET? If in VB.NET, there would be a smaller pool of potential maintainers, but OTOH I imagine someone unfamiliar with VB.NET would be uninterested in contributing to a VB.NET analyzer in any case. Also, since VB.NET doesn't yet support pattern matching, the code would be somewhat less elegant. (Not sure if that is a consideration, but just putting it out there.) |
I think there is no reason you can't write it in C#, in fact I looked at it, and all though it would be hard to come up with unit tests :) but using code from C# implementation, it may in fact be easier to write it in C#. In any case, should you choose to write it in VB.NET I have no problems in it residing here since it will beneficial to a broader audience. |
Hi. I simply join the request to add support for VB.NET. Thanks for share. |
Why not try to re-write the existing analyzers as operation analyzers? That has many benefits:
Probably not all analyzers can be rewritten as IOperation analyzers, but some of them can. |
Using version 2.0 of the VS extension.
Creating a new VB.NET Windows Desktop project, and typing the following code:
doesn't raise any warning about implicit allocations, as the following C# code would:
The text was updated successfully, but these errors were encountered: