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

CodeMaid Spade: Visual Basic comments are not displayed #326

Closed
JetpackDuba opened this issue Aug 16, 2016 · 16 comments
Closed

CodeMaid Spade: Visual Basic comments are not displayed #326

JetpackDuba opened this issue Aug 16, 2016 · 16 comments

Comments

@JetpackDuba
Copy link
Contributor

Environment

  • Visual Studio version: 2015 Community
  • CodeMaid version: 10.1
  • Code language: VB .NET

Description

Documentation comments are not displayed in CodeMaid Spade using VB .NET but they work using C#. Is this an issue?

Steps to recreate

  1. Create an example method with documentation comments.
  2. Check CodeMaid Spade.
    2016-08-16 16_56_13-consoleapplication5 - microsoft visual studio
    2016-08-16 16_56_27-consoleapplication1 - microsoft visual studio

Current behavior

Comments are not displayed.

Expected behavior

Comments should be displayed.

@codecadwallader
Copy link
Owner

Thanks for reporting the issue, I have reproduced it. I found a minor discrepancy in how VB and C# report the XML hierarchy that was causing us not to present the comment in the case of VB. There was a very simple fix for it, which I've committed and will be available in our CI channel in a few moments (10.1.100 or higher) if you would like to test it out. This will be a part of the next minor release as well.

Thanks again!

@JetpackDuba
Copy link
Contributor Author

Now it is working! Thanks for fixing it!
2016-08-18 09_41_13-consoleapplication5 - microsoft visual studio
2016-08-18 09_41_24-consoleapplication6 - microsoft visual studio

@codecadwallader
Copy link
Owner

Woot, thanks for confirming. :)

@codecadwallader
Copy link
Owner

Let's leave this open until it's out in an official release, that makes it a little easier for other users to discover.

@JetpackDuba
Copy link
Contributor Author

Oh, oke! Sorry, my bad!

@codecadwallader
Copy link
Owner

All good :)
On Fri, Aug 19, 2016 at 2:58 PM aeab13 notifications@github.com wrote:

Oh, oke! Sorry, my bad!


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#326 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADpYnAMRT5qShsnTJ4H9kIP58qmrb07xks5qhfzcgaJpZM4JlgOA
.

tmccowan added a commit to tmccowan/codemaid that referenced this issue Aug 23, 2016
codecadwallader#326: Fix for how VB DocComment's are parsed vs. C# DocComment's.
@JetpackDuba
Copy link
Contributor Author

I've noticed that sometimes the problem persists. I add here a screenshot but I'm not sure about how it can be reproduced.
microsoft visual studio

@codecadwallader
Copy link
Owner

It looks like you have some unsaved changes. The code model is built on load (or refresh or save) but will not live update so that may be the cause? A live updating model is something we'd love to have in the future, but will require a large rewrite to Roslyn APIs.

@JetpackDuba
Copy link
Contributor Author

Nope, I'm testing it againt but everything is saved correctly, it's really weird. I've closed the project and I've reopened it but the problem persists.

@JetpackDuba
Copy link
Contributor Author

JetpackDuba commented Sep 12, 2016

Note: I've noticed that in the same class, in some methods the description is displayed but in the other methods the comments are not displayed. I'm not sure of what is failing.

@codecadwallader
Copy link
Owner

That is strange. Can you provide the file? Perhaps there is something different in the formatting that is causing it not to get recognized.

@JetpackDuba
Copy link
Contributor Author

JetpackDuba commented Sep 16, 2016

Yeah! And sorry for the late answer.
CalculosController.zip

@JetpackDuba
Copy link
Contributor Author

JetpackDuba commented Sep 17, 2016

I'm debugging it and it seems that it is crashing when there are multiple documentation tags.
Look at DocCommentToStringConverter class
var xElement = XElement.Parse(str);

For example:
This is working:

    ''' <summary>
    ''' This is a test
    ''' </summary>

This not:

    ''' <summary>
    ''' Test
    ''' </summary>
    ''' <param name="price">Price test</param>

I'm trying to resolve it.

EDIT:
The string passed as parameter in this class in C# has the root tag "<doc>" but there isn't this tag when using VB .NET.

EDIT2:
It may be a bit weird/stupid but for now I've added this piece of code in DocCommentToStringConverter class to make it work. Now it works perfectly in C# and VB.
I've never worked with VS pluggins so I am not really sure about how they work and if my change is correct or not. I'm sorry that I can't help more.

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var str = value as string;
            if (string.IsNullOrEmpty(str)) return string.Empty;

            try
            {
                //In VB .NET the returned XML hasn't a <doc> tag so we add it to avoid a crash with multiple documentation tags

                if (!str.StartsWith("<doc>"))
                    str = "<doc>" + str + "</doc>";


                var xElement = XElement.Parse(str);

                var summaryTag = xElement.DescendantsAndSelf("summary").FirstOrDefault();
                if (summaryTag == null) return string.Empty;

                // Get the Inner XML for the summary tag.
                var result = GetInnerXML(summaryTag);

                // Replace para tags with two new lines.
                result = Regex.Replace(result, @"</?para ?/?> ?", Environment.NewLine + Environment.NewLine);

                // Reduce three of more new lines down to two.
                result = Regex.Replace(result, @"(\r?\n){3,}", Environment.NewLine + Environment.NewLine);

                // Trim off any leading/trailing whitespace including newlines.
                result = result.Trim();

                return result;
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }

@codecadwallader
Copy link
Owner

I wonder if it's because they're not well-formatted XML (i.e. there is no
single root element) - even though that is the correct convention for
documentation comments. I remembered making this specific tweak to support
VB since it does not auto-create a single root element, which the C# API
did:
00460f3

Perhaps another fix would be to insert and append XML to the front and end
of the string before sending it to XElement.Parse? We'd have to make sure
that didn't interfere with the other scenarios (e.g. single doc tag or C#).

On Sat, Sep 17, 2016 at 3:06 PM Abdelilah El Aissaoui <
notifications@github.com> wrote:

I'm debugging it and it seems that it is crashing when there are multiple
documentation tags.
Look at DocCommentToStringConverter class
var xElement = XElement.Parse(str);

For example:
This is working:

''' <summary>
''' This is a test
''' </summary>

This not:

''' <summary>
''' Test
''' </summary>
''' <param name="price">Price test</param>

I'm trying to resolve it.


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#326 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADpYnFB71qbzLyndFNaIKu1HIXmbjgX6ks5qrDo7gaJpZM4JlgOA
.

@codecadwallader
Copy link
Owner

Ha! Just saw your edits and that's exactly what I was thinking too. :) Do you mind making that into a pull request?

@JetpackDuba
Copy link
Contributor Author

Yeah, sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants