Repository navigation
Catch exceptions from user code #1139
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System.ComponentModel.Composition; | ||
| using Microsoft.CodeAnalysis.Diagnostics; | ||
| using Microsoft.Internal.VisualStudio.PlatformUI; | ||
| using Microsoft.VisualStudio.Shell; | ||
| using Microsoft.VisualStudio.Utilities; | ||
|
|
@@ -15,11 +16,14 @@ internal sealed class DiagnosticItemProvider : AttachedCollectionSourceProvider< | |
| [Import(typeof(AnalyzersCommandHandler))] | ||
| private IAnalyzersCommandHandler _commandHandler = null; | ||
|
|
||
| [Import] | ||
| private IDiagnosticAnalyzerService _diagnosticAnalyzerService = null; | ||
|
|
||
| protected override IAttachedCollectionSource CreateCollectionSource(AnalyzerItem item, string relationshipName) | ||
| { | ||
| if (relationshipName == KnownRelationships.Contains) | ||
| { | ||
| return new DiagnosticItemSource(item, _commandHandler); | ||
| return new DiagnosticItemSource(item, _commandHandler, (DiagnosticAnalyzerService)_diagnosticAnalyzerService); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this cast is safe, why isn't the type of the field DiagnosticAnalyzerService?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also consider just adding the GetDiagnosticDescriptors(Analyzer) method to IDiagnosticAnalyzerService interface.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tmeschter can we just do that as part of this change? |
||
| } | ||
|
|
||
| return null; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this field ever get a value other than null? I'm guessing the [Import] does something magic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is MEF magic.