protected override DiagnosticAnalyzer CreateAnalyzer() { BaseAnalyzer analyzer = CreateNullabilityAnalyzer(); analyzer.ExternalAnnotationsResolver.Override(externalAnnotationsResolver); analyzer.NullabilityAttributeProvider.Override(new SimpleNullabilityAttributeProvider()); return(analyzer); }
private AnalyzeResult GetResultFromAnalyzer(BaseAnalyzer baseAnalyzerInstance) { var pageData = new PageData { Document = HtmlResult.Document, Focuskeyword = FocusKeyword, Url = Url }; return(baseAnalyzerInstance.Analyse(pageData)); }
private ProblemCollection CheckSymbol([CanBeNull] ISymbol symbol) { if (symbol != null) { // When unable to load external annotations, the rule would likely report lots // of false positives. This is prevented by letting it throw here and report nothing. IExternalAnnotationsResolver resolver = ExternalAnnotationsResolver.GetCached(); resolver.EnsureScanned(); var analyzerFactory = new AnalyzerFactory(resolver, appliesToItem); BaseAnalyzer analyzer = analyzerFactory.CreateFor(symbol); analyzer.Analyze(ReportProblem); } return(Problems); }
public void PreInit() { PTMagicMonitorBasePath = Directory.GetCurrentDirectory(); if (!System.IO.File.Exists(PTMagicMonitorBasePath + Path.DirectorySeparatorChar + "appsettings.json")) { PTMagicMonitorBasePath += Path.DirectorySeparatorChar + "Monitor"; } if (!PTMagicMonitorBasePath.EndsWith(Path.DirectorySeparatorChar)) { PTMagicMonitorBasePath += Path.DirectorySeparatorChar; } IConfiguration config = new ConfigurationBuilder() .SetBasePath(PTMagicMonitorBasePath) .AddJsonFile("appsettings.json", false) .Build(); PTMagicBasePath = config.GetValue <string>("PTMagicBasePath"); if (!PTMagicBasePath.EndsWith(Path.DirectorySeparatorChar)) { PTMagicBasePath += Path.DirectorySeparatorChar; } try { PTMagicConfiguration = new PTMagicConfiguration(PTMagicBasePath); } catch (Exception ex) { throw ex; } IServiceProvider logProvider = ServiceHelper.BuildLoggerService(PTMagicBasePath); Log = logProvider.GetRequiredService <LogHelper>(); Summary = JsonConvert.DeserializeObject <Summary>(System.IO.File.ReadAllText(PTMagicBasePath + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "LastRuntimeSummary.json")); if (Summary.CurrentGlobalSetting == null) { Summary.CurrentGlobalSetting = PTMagicConfiguration.AnalyzerSettings.GlobalSettings.Find(s => s.SettingName.IndexOf("default", StringComparison.InvariantCultureIgnoreCase) > -1); } MainFiatCurrencySymbol = SystemHelper.GetCurrencySymbol(Summary.MainFiatCurrency); try { // Get latest release from GitHub if (!String.IsNullOrEmpty(HttpContext.Session.GetString("LatestVersion"))) { LatestVersion = HttpContext.Session.GetString("LatestVersion"); } else { LatestVersion = BaseAnalyzer.GetLatestGitHubRelease(Log, Summary.Version); HttpContext.Session.SetString("LatestVersion", LatestVersion); } } catch { } try { // Get current bot version if (!String.IsNullOrEmpty(HttpContext.Session.GetString("CurrentBotVersion"))) { CurrentBotVersion = HttpContext.Session.GetString("CurrentBotVersion"); } else { string ptMagicBotDllPath = PTMagicBasePath + "PTMagic.dll"; if (System.IO.File.Exists(ptMagicBotDllPath)) { FileVersionInfo ptMagicDllInfo = FileVersionInfo.GetVersionInfo(ptMagicBotDllPath); CurrentBotVersion = ptMagicDllInfo.ProductVersion.Substring(0, ptMagicDllInfo.ProductVersion.LastIndexOf(".")); HttpContext.Session.SetString("CurrentBotVersion", CurrentBotVersion); } else { CurrentBotVersion = Summary.Version; } } } catch { CurrentBotVersion = Summary.Version; } }