Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

XUnitConverter not working #266

@philwindsor

Description

@philwindsor

I've had nothing but trouble trying to get this to work and have hit yet another issue.

 SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            List<UsingDirectiveSyntax> newUsings = new List<UsingDirectiveSyntax>();
            bool needsChanges = false;

            foreach (var usingSyntax in root.Usings)
            {
                var symbolInfo = semanticModel.GetSymbolInfo(usingSyntax.Name);
                if (symbolInfo.Symbol != null)
                {
                    string namespaceDocID = symbolInfo.Symbol.GetDocumentationCommentId();
                    if (s_mstestNamespaces.Contains(namespaceDocID))
                    {
                        needsChanges = true;
                    }
                    else
                    {
                        newUsings.Add(RemoveLeadingAndTrailingCompilerDirectives(usingSyntax));
                    }
                }
                else
                {
                    newUsings.Add(RemoveLeadingAndTrailingCompilerDirectives(usingSyntax));
                }
            }

            if (!needsChanges)
            {
                return document.Project.Solution;
            }

The above code is from MSTestToXUnitConverter.cs. The issue is when it gets to the using statement for Microsoft.VisualStudio.TestTools.UnitTesting symbolInfo.Symbol is null so it doesn't hit the code inside the if statement

Does anyone know why this is and how to fix it? I'm using visual studio 2017

Activity

JayCroghan

JayCroghan commented on Jul 3, 2019

@JayCroghan

So this two year old issue hasn't been even commented on, I have the exact same issue in 2019. At first it wasn't even getting my list of usings because they are inside the namespace, but now that I figured that out and moved them it's returning Symbol as null here and ignoring the file.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JayCroghan@philwindsor

        Issue actions

          XUnitConverter not working · Issue #266 · dotnet/codeformatter