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

Fixed GoToMetadata in CSX #829

Merged
merged 6 commits into from
Apr 21, 2017

Conversation

filipw
Copy link
Member

@filipw filipw commented Apr 19, 2017

Fixes #755

At the moment Go To Metadata doesn't work in CSX files. The reason is, in the current implementation of metadata handling on the server, a metadata-document was added to current project. This is not allowed in submission type projects (which are used for CSX files), as they can only have one root syntax tree, cannot have namespaces etc. - and an ugly unhandled exception was thrown instead. To fix this, we actually create a temporary project (which is thrown away) for CSX metadata navigation.

The fix doesn't affect the original code path so there is no risk merging this. However similar implementation (a temporary project) could also be considered there, because at the moment we flood the current project with new documents every time metadata is accessed. I left it intact because perhaps there was some reason to implement it like that?

I also added GoToMetadata tests for CSX to validate this fix.

// we will use temporary project to hold metadata documents
var metadataProject = project.IsSubmission ? project.Solution.AddProject("metadataTemp", "metadataTemp.dll", LanguageNames.CSharp).
WithCompilationOptions(project.CompilationOptions).
WithMetadataReferences(project.MetadataReferences) : project;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny, tiny, tiny nit: This might be more readable if formatted like so:

C#

var metadataProject = project.IsSubmission
    ? project.Solution.AddProject("metadataTemp", "metadataTemp.dll", LanguageNames.CSharp)
        .WithCompilationOptions(project.CompilationOptions)
        .WithMetadataReferences(project.MetadataReferences)
    : project;

@@ -136,7 +136,12 @@ public void AddFilesToWorkspace(params TestFile[] testFiles)
this.Workspace,
"project.json",
new[] { "dnx451", "dnxcore50" },
testFiles);
testFiles.Where(f => f.FileName.EndsWith(".cs", StringComparison.CurrentCultureIgnoreCase)).ToArray());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want CurrentCulture? Should that be OrdinalIgnoreCase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sure, I just picked "that long thing" from intellisense without thinking twice

Copy link
Member

@david-driscoll david-driscoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 :shipit:

@DustinCampbell DustinCampbell merged commit 9aa19af into OmniSharp:dev Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants