#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionAnalysis.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty); await FeedbackCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await MoveAllHardCodedStringsToResourceFileCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await this.SetUpRunningDocumentTableEventsAsync(cancellationToken); RapidXamlDocumentCache.Initialize(this, SharedRapidXamlPackage.Logger); Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution += this.HandleCloseSolution; } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }
#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger.RecordNotice(StringRes.Info_LaunchVersionGeneration.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger.RecordNotice(string.Empty); await CopyToClipboardCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await SendToToolboxCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await OpenOptionsCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await RapidXamlDropHandlerProvider.InitializeAsync(this, SharedRapidXamlPackage.Logger); // Set the ServiceProvider of CodeParserBase as it's needed to get settings CodeParserBase.ServiceProvider = this; if (SharedRapidXamlPackage.Logger != null) { SharedRapidXamlPackage.Logger.UseExtendedLogging = CodeParserBase.GetSettings().ExtendedOutputEnabled; } } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }
#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionRoslynAnalyzers.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty); } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }
#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionAnalysis.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty); await FeedbackCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await MoveAllHardCodedStringsToResourceFileCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await AnalyzeCurrentDocumentCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await OpenAnalysisOptionsCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await this.SetUpRunningDocumentTableEventsAsync(cancellationToken); RapidXamlDocumentCache.Initialize(this, SharedRapidXamlPackage.Logger); Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution += this.HandleCloseSolution; // Handle the ability to resolve assemblies when loading custom analyzers. // Hat-tip: https://weblog.west-wind.com/posts/2016/dec/12/loading-net-assemblies-out-of-seperate-folders AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) => { // Ignore missing resources if (args.Name.Contains(".resources")) { return(null); } if (args.RequestingAssembly == null) { return(null); } // check for assemblies already loaded var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name); if (assembly != null) { return(assembly); } // Try to load by filename - split out the filename of the full assembly name // and append the base path of the original assembly (ie. look in the same dir) string filename = args.Name.Split(',')[0] + ".dll".ToLower(); var asmFile = Path.Combine(Path.GetDirectoryName(args.RequestingAssembly.CodeBase), filename); if (asmFile.StartsWith("file:\\")) { asmFile = asmFile.Substring(6); } try { return(Assembly.LoadFrom(asmFile)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); return(null); } }; // Track this so don't try and load CustomAnalyzers while VS is still starting up. RapidXamlAnalysisPackage.IsLoaded = true; RapidXamlAnalysisPackage.Options = (AnalysisOptionsGrid)this.GetDialogPage(typeof(AnalysisOptionsGrid)); var ass = Assembly.GetExecutingAssembly().GetName(); SharedRapidXamlPackage.Logger?.RecordFeatureUsage(StringRes.Info_PackageLoad.WithParams(ass.Name, ass.Version), quiet: true); } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }