Пример #1
0
            public override void HandleException(object provider, Exception exception)
            {
                if (provider is CodeFixProvider || provider is FixAllProvider || provider is CodeRefactoringProvider)
                {
                    if (!IsIgnored(provider) &&
                        _optionsService.GetOption(ExtensionManagerOptions.DisableCrashingExtensions))
                    {
                        base.HandleException(provider, exception);

                        _errorReportingService?.ShowErrorInfoForCodeFix(
                            codefixName: provider.GetType().Name,
                            OnEnable: () => { EnableProvider(provider); LogEnableProvider(provider); },
                            OnEnableAndIgnore: () => { EnableProvider(provider); IgnoreProvider(provider); LogEnableAndIgnoreProvider(provider); },
                            OnClose: () => LogLeaveDisabled(provider));
                    }
                    else
                    {
                        LogAction(CodefixInfobar_ErrorIgnored, provider);
                    }
                }
                else
                {
                    if (_optionsService.GetOption(ExtensionManagerOptions.DisableCrashingExtensions))
                    {
                        base.HandleException(provider, exception);
                    }

                    _errorHandlers.Do(h => h.HandleError(provider, exception));
                }

                _errorLoggerService?.LogException(provider, exception);
            }
            public override void HandleException(object provider, Exception exception)
            {
                if (provider is CodeFixProvider || provider is FixAllProvider || provider is CodeRefactoringProvider)
                {
                    if (!IsIgnored(provider) &&
                        _optionsService.GetOption(ExtensionManagerOptions.DisableCrashingExtensions))
                    {
                        base.HandleException(provider, exception);

                        _errorReportingService?.ShowErrorInfoInActiveView(String.Format(WorkspacesResources._0_encountered_an_error_and_has_been_disabled, provider.GetType().Name),
                                                                          new InfoBarUI(WorkspacesResources.Show_Stack_Trace, InfoBarUI.UIKind.HyperLink, () => ShowDetailedErrorInfo(exception), closeAfterAction: false),
                                                                          new InfoBarUI(WorkspacesResources.Enable, InfoBarUI.UIKind.Button, () => { EnableProvider(provider); LogEnableProvider(provider); }),
                                                                          new InfoBarUI(WorkspacesResources.Enable_and_ignore_future_errors, InfoBarUI.UIKind.Button, () => { EnableProvider(provider); IgnoreProvider(provider); LogEnableAndIgnoreProvider(provider); }),
                                                                          new InfoBarUI(String.Empty, InfoBarUI.UIKind.Close, () => LogLeaveDisabled(provider)));
                    }
                    else
                    {
                        LogAction(CodefixInfobar_ErrorIgnored, provider);
                    }
                }
                else
                {
                    if (_optionsService.GetOption(ExtensionManagerOptions.DisableCrashingExtensions))
                    {
                        base.HandleException(provider, exception);
                    }

                    _errorHandlers.Do(h => h.HandleError(provider, exception));
                }

                _errorLoggerService?.LogException(provider, exception);
            }
Пример #3
0
            public bool TryGetDocumentOption(OptionKey option, OptionSet underlyingOptions, out object value)
            {
                var editorConfigPersistence = option.Option.StorageLocations.OfType <IEditorConfigStorageLocation>().SingleOrDefault();

                if (editorConfigPersistence == null)
                {
                    value = null;
                    return(false);
                }

                // Temporarly map our old Dictionary<string, object> to a Dictionary<string, string>. This can go away once we either
                // eliminate the legacy editorconfig support, or we change IEditorConfigStorageLocation.TryGetOption to take
                // some interface that lets us pass both the Dictionary<string, string> we get from the new system, and the
                // Dictionary<string, object> from the old system.
                //
                // We cache this with a conditional weak table so we're able to maintain the assumptions in EditorConfigNamingStyleParser
                // that the instance doesn't regularly change and thus can be used for further caching
                var allRawConventions = s_convertedDictionaryCache.GetValue(
                    _codingConventionSnapshot.AllRawConventions,
                    d => ImmutableDictionary.CreateRange(d.Select(c => KeyValuePairUtil.Create(c.Key, c.Value.ToString()))));

                try
                {
                    var underlyingOption = underlyingOptions.GetOption(option);
                    return(editorConfigPersistence.TryGetOption(underlyingOption, allRawConventions, option.Option.Type, out value));
                }
                catch (Exception ex)
                {
                    _errorLogger?.LogException(this, ex);
                    value = null;
                    return(false);
                }
            }
            public override void HandleException(object provider, Exception exception)
            {
                if (provider is CodeFixProvider || provider is FixAllProvider || provider is CodeRefactoringProvider)
                {
                    if (!IsIgnored(provider) &&
                        _optionsService.GetOption(ExtensionManagerOptions.DisableCrashingExtensions))
                    {
                        base.HandleException(provider, exception);

                        _errorReportingService?.ShowErrorInfoForCodeFix(
                            provider.GetType().Name,
                            () => EnableProvider(provider),
                            () => { EnableProvider(provider); IgnoreProvider(provider); });
                    }
                }
                else
                {
                    if (_optionsService.GetOption(ExtensionManagerOptions.DisableCrashingExtensions))
                    {
                        base.HandleException(provider, exception);
                    }

                    _errorHandlers.Do(h => h.HandleError(provider, exception));
                }

                _errorLoggerService?.LogException(provider, exception);
            }
Пример #5
0
            public override void HandleException(object provider, Exception exception)
            {
#if !DEBUG
                // Disable info bar for crashing analyzers in release builds.
                if (provider is CodeFixProvider || provider is FixAllProvider || provider is CodeRefactoringProvider)
                {
                    errorLoggerService?.LogException(provider, exception);
                    return;
                }
#endif
                base.HandleException(provider, exception);
            }
            public override void HandleException(object provider, Exception exception)
            {
#if !DEBUG
                // Disable info bar for crashing analyzers in release builds.
                if (provider is CodeFixProvider || provider is FixAllProvider || provider is CodeRefactoringProvider)
                {
                    errorLoggerService?.LogException(provider, exception);
                    return;
                }
#endif
                // HACK: Let Roslyn's CSharpSemanticQuickInfoProvider throw as many errors as it wants without becoming
                //       disabled. This is just a temporary workaround until we find the right fix for
                //       https://devdiv.visualstudio.com/DevDiv/_workitems/edit/960181 .
                //       Without this, as soon as the above bug is hit, most useful C# tooltips stop appearing until
                //       you close/reopen the solution.
                if (provider.GetType().FullName == "Microsoft.CodeAnalysis.CSharp.QuickInfo.CSharpSemanticQuickInfoProvider")
                {
                    errorLoggerService?.LogException(provider, exception);
                    return;
                }

                base.HandleException(provider, exception);
            }
                public bool TryGetDocumentOption(OptionKey option, out object?value)
                {
                    var editorConfigPersistence = option.Option.StorageLocations.OfType <IEditorConfigStorageLocation>().SingleOrDefault();

                    if (editorConfigPersistence == null)
                    {
                        value = null;
                        return(false);
                    }

                    try
                    {
                        return(editorConfigPersistence.TryGetOption(_options, option.Option.Type, out value));
                    }
                    catch (Exception ex)
                    {
                        _errorLogger?.LogException(this, ex);
                        value = null;
                        return(false);
                    }
                }
            public bool TryGetDocumentOption(Document document, OptionKey option, out object value)
            {
                var editorConfigPersistence = option.Option.StorageLocations.OfType <EditorConfigStorageLocation>().SingleOrDefault();

                if (editorConfigPersistence == null)
                {
                    value = null;
                    return(false);
                }

                var allRawConventions = _codingConventionSnapshot.AllRawConventions;

                try
                {
                    return(editorConfigPersistence.TryParseReadonlyDictionary(allRawConventions, option.Option.Type, out value));
                }
                catch (Exception ex)
                {
                    _errorLogger?.LogException(this, ex);
                    value = null;
                    return(false);
                }
            }
Пример #9
0
            public bool TryGetDocumentOption(OptionKey option, OptionSet underlyingOptions, out object value)
            {
                var editorConfigPersistence = option.Option.StorageLocations.OfType <IEditorConfigStorageLocation>().SingleOrDefault();

                if (editorConfigPersistence == null)
                {
                    value = null;
                    return(false);
                }

                var allRawConventions = _codingConventionSnapshot.AllRawConventions;

                try
                {
                    var underlyingOption = underlyingOptions.GetOption(option);
                    return(editorConfigPersistence.TryGetOption(underlyingOption, allRawConventions, option.Option.Type, out value));
                }
                catch (Exception ex)
                {
                    _errorLogger?.LogException(this, ex);
                    value = null;
                    return(false);
                }
            }