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

Load XML docs when using #r directives in scripting #1027

Merged
merged 7 commits into from
Nov 13, 2017

Conversation

filipw
Copy link
Member

@filipw filipw commented Nov 13, 2017

Fixes #1026

At the moment, the RuntimeMetadataReferenceResolver on which we rely when processing #r directives in scripts, completely ignores XML docs https://github.com/dotnet/roslyn/blob/version-2.4.0/src/Scripting/Core/Hosting/Resolvers/RuntimeMetadataReferenceResolver.cs#L69

There is no simple hook in which we can inject it (unless we rewrite/copy entire resolver and all its dependencies), so the fix is applied via 😔 reflection 😔. I'll talk to Tomas to see if we can do something better on the Scripting API side, but for now this should at least fix the problem.

Also attached a test that verifies the functionality.

Copy link
Contributor

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

Looks good! Just tiny nits from me.

@@ -7,11 +7,19 @@
using Microsoft.CodeAnalysis.Scripting;
using Microsoft.CodeAnalysis.Scripting.Hosting;
using Microsoft.Extensions.Configuration;
using System.IO;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: sort System using directives on top.

@@ -5,6 +5,7 @@
using TestUtility;
using Xunit;
using Xunit.Abstractions;
using System.IO;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sort usings with System namespaces an top

@@ -215,6 +215,7 @@ private void AddMetadataReference(ISet<MetadataReference> referenceCollection, s
_logger.LogDebug($"Added reference to '{fileReference}'");
}


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Extra blank line

return MetadataReference.CreateFromFile(path, properties, documentationProvider);
}));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extra blank line.

: new CachingScriptMetadataResolver(ScriptMetadataResolver.Default);
return enableScriptNuGetReferences ?
new CachingScriptMetadataResolver(new NuGetMetadataReferenceResolver(_resolver)) :
new CachingScriptMetadataResolver(_resolver);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: for this conditional expression, you have the ? and : at the end of the lines. However, below, you have them at the start of the lines. Maybe make these consistent? (I personally prefer the bottom one.)

@@ -47,7 +47,7 @@ public MetadataReference GetMetadataReference(string filePath)
}

var displayText = assemblyMetadata.GetModules().FirstOrDefault()?.Name;

Copy link
Contributor

Choose a reason for hiding this comment

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

unintentional whitespace-only change?

@filipw
Copy link
Member Author

filipw commented Nov 13, 2017

thanks! pushed the requested changes. Also added a changelog entry that I forgot before.

@DustinCampbell DustinCampbell merged commit 8c0ce0f into OmniSharp:master Nov 13, 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.

Editing .csx: XML Docs of own libraries are not displayed in Intellisense popups
2 participants