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
aeab13 opened this Issue Aug 16, 2016 · 16 comments

Comments

Projects
None yet
2 participants
@aeab13
Contributor

aeab13 commented Aug 16, 2016

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 added a commit that referenced this issue Aug 18, 2016

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Aug 18, 2016

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!

@aeab13

This comment has been minimized.

Contributor

aeab13 commented Aug 18, 2016

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

This comment has been minimized.

Owner

codecadwallader commented Aug 18, 2016

Woot, thanks for confirming. :)

@aeab13 aeab13 closed this Aug 19, 2016

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Aug 19, 2016

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

@aeab13

This comment has been minimized.

Contributor

aeab13 commented Aug 19, 2016

Oh, oke! Sorry, my bad!

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Aug 19, 2016

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

Merge pull request #1 from codecadwallader/master
codecadwallader#326: Fix for how VB DocComment's are parsed vs. C# DocComment's.
@aeab13

This comment has been minimized.

Contributor

aeab13 commented Sep 7, 2016

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

This comment has been minimized.

Owner

codecadwallader commented Sep 7, 2016

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.

@aeab13

This comment has been minimized.

Contributor

aeab13 commented Sep 7, 2016

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.

@aeab13

This comment has been minimized.

Contributor

aeab13 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

This comment has been minimized.

Owner

codecadwallader commented Sep 12, 2016

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

@aeab13

This comment has been minimized.

Contributor

aeab13 commented Sep 16, 2016

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

@aeab13

This comment has been minimized.

Contributor

aeab13 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

This comment has been minimized.

Owner

codecadwallader commented Sep 17, 2016

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

This comment has been minimized.

Owner

codecadwallader commented Sep 17, 2016

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

@aeab13

This comment has been minimized.

Contributor

aeab13 commented Sep 17, 2016

Yeah, sure!

@aeab13 aeab13 closed this Dec 8, 2016

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