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

Check if file exist before trying to create MetadataReference. #1045

Merged

Conversation

bjorkstromm
Copy link
Member

Just to avoid throwing any uneccesary exceptions.

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.

LGTM

@@ -148,7 +148,7 @@ private void ScriptReferencesChanged(object sender, ReferencesChangedEventArgs e
var document = solution.GetDocument(documentId);
var project = document.Project;

var metadataReferences = e.References.Select(reference => MetadataReference.CreateFromFile(reference, documentation: GetDocumentationProvider(reference)));
var metadataReferences = GetMetadataReferences(e.References);
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, e.References should be ISet<string> and not IReadOnlyCollection<string>, so duplicates should already be avoided.

Copy link
Contributor

Choose a reason for hiding this comment

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

@filipw is referring to the issue of adding the same assembly reference to a project twice. This can happen if there are multiple copies of the same assembly with different file paths.

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, then I understand. I'll update!

@DustinCampbell
Copy link
Contributor

Just asking out of curiosity -- should you really just be using the MetadataFileCacheService?

@bjorkstromm
Copy link
Member Author

@DustinCampbell yes, I should be using that! 😄 Will rework this PR to use that instead.

- Use MetadataFileReferenceCache when loading metadatareferences
- ReferencesChangedEventArgs.References should be of type ISet<string>
Copy link
Member

@filipw filipw 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, the test failure is caused by nuget failure atm

@david-driscoll
Copy link
Member

AppVeyor seems to have died getting nuget pacakges. kicking.

@david-driscoll david-driscoll merged commit 4ce9ad7 into OmniSharp:master Dec 11, 2017
@bjorkstromm bjorkstromm deleted the feature/check-if-reference-exist branch December 11, 2017 21:56
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.

4 participants