예제 #1
0
        public void ShouldChainCorrectly()
        {
            // Arrange
            var logStrategy = new Mock <ILogStrategy>();

            logStrategy.Setup(x => x.WriteMessage(It.IsAny <string>())).Verifiable();

            var debugLogger = new DiagnosticLogger().Init(LogLevel.Debug, logStrategy.Object);
            var infoLogger  = new DiagnosticLogger().Init(LogLevel.Info, logStrategy.Object);
            var fatalLogger = new DiagnosticLogger().Init(LogLevel.Fatal, logStrategy.Object);

            debugLogger.SetNextLogger(infoLogger);
            infoLogger.SetNextLogger(fatalLogger);

            // Act
            debugLogger.LogMessage(LogLevel.Debug, "debug");
            debugLogger.LogMessage(LogLevel.Info, "info");
            debugLogger.LogMessage(LogLevel.Fatal, "fatal");

            // Assert
            logStrategy.Verify(x => x.WriteMessage(It.IsAny <string>()), Times.Exactly(3));
            logStrategy.Verify(
                x => x.WriteMessage(It.Is <string>(s => s.Contains($"{LogLevel.Debug}") && ValidateLog(s))), Times.Once);
            logStrategy.Verify(
                x => x.WriteMessage(It.Is <string>(s => s.Contains($"{LogLevel.Info}") && ValidateLog(s))), Times.Once);
            logStrategy.Verify(
                x => x.WriteMessage(It.Is <string>(s => s.Contains($"{LogLevel.Fatal}") && ValidateLog(s))), Times.Once);
        }
예제 #2
0
        /// <summary>
        /// All static classes and singletons meant for global
        /// usage are activated here. Some areas depend on these classes having their
        /// data loaded before the program starts (e.g., OdometerTracker), so it
        /// is very important that they are called here. All static classes should at
        /// the bare minimum implement an empty Activate() method to ensure their
        /// constructors are called
        /// </summary>
        private void ActivateStaticClasses()
        {
            EventBridge.Initialize();
            DiagnosticsParser.Initialize();
            CanMessageHandler.Initialize();
            ConfigManager.LoadConfiguration();
            DiagnosticLogger.Initialize();
            RawLogger.Initialize();
            PIDValueStager.Initialize();
            _EngineDataParser = new EngineDataParser();
            _Acceleration     = new Acceleration();
            _Trackers         = new Trackers();
            ChassisParameters.Initialize();
            var engineFilePointer = new FileOpener(ConfigManager.Settings.Contents.engineFilePath);

            if (engineFilePointer.Exists())
            {
                EngineSpec.SetEngineFile(engineFilePointer.absoluteFilepath);
            }
            else
            {
                MessageBox.Show("No engine files can be found. Horsepower and Torque settings will be inaccurate");
            }
            SPNDefinitions.Activate();      //in VMSpc/Parsers/J1939/SPNDefinitions.cs - Defines every SPN object
            //Odometer.Activate();
            //ParamData.Activate();
            TireManager.Initialize();
            CommunicationManager.Initialize();
            DayNightManager.Initialize();
        }
예제 #3
0
        /// <summary>
        /// Gets the or create builder.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="startupInstance">The startup instance.</param>
        /// <param name="environment">The environment.</param>
        /// <returns>RocketFunctionHostBuilder.</returns>
        internal static RocketFunctionHostBuilder GetOrCreateBuilder(IWebJobsBuilder builder, object startupInstance, IRocketEnvironment environment)
        {
            if (!Builders.TryGetValue(builder, out var conventionalBuilder))
            {
                var diagnosticSource  = new DiagnosticListener("Rocket.Surgery.Hosting");
                var functionsAssembly = startupInstance.GetType().Assembly;

                var location = Path.GetDirectoryName(functionsAssembly.Location);
                DependencyContext dependencyContext = null;
                while (dependencyContext == null && !string.IsNullOrEmpty(location))
                {
                    var depsFilePath = Path.Combine(location, functionsAssembly.GetName().Name + ".deps.json");
                    if (File.Exists(depsFilePath))
                    {
                        using (var stream = File.Open(depsFilePath, FileMode.Open, FileAccess.Read))
                        {
                            dependencyContext = new DependencyContextJsonReader().Read(stream);
                            break;
                        }
                    }
                    location = Path.GetDirectoryName(location);
                }
                var logger = new DiagnosticLogger(diagnosticSource);
                var assemblyCandidateFinder = new DependencyContextAssemblyCandidateFinder(dependencyContext, logger);
                var assemblyProvider        = new DependencyContextAssemblyProvider(dependencyContext, logger);
                var properties = new ServiceProviderDictionary();
                var scanner    = new SimpleConventionScanner(assemblyCandidateFinder, properties, logger);
                conventionalBuilder = new RocketFunctionHostBuilder(builder, functionsAssembly, startupInstance, environment, scanner, assemblyCandidateFinder, assemblyProvider, diagnosticSource, properties);
                Builders.Add(builder, conventionalBuilder);
            }

            return(conventionalBuilder);
        }
예제 #4
0
        private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            if (e.Uri == null)
            {
                return;
            }

            BrowserHelper.StartBrowser(_serviceProvider, e.Uri);
            e.Handled = true;

            var hyperlink = sender as Hyperlink;

            if (hyperlink == null)
            {
                return;
            }

            var item = hyperlink.Tag as DiagnosticData;

            if (item == null)
            {
                return;
            }

            var telemetry = item.CustomTags.Any(t => t == WellKnownDiagnosticTags.Telemetry);

            DiagnosticLogger.LogHyperlink("ErrorList", item.Id, item.Description != null, telemetry, e.Uri.AbsoluteUri);
        }
        /// <summary>
        /// Gets the or create builder.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns>RocketHostBuilder.</returns>
        internal static RocketHostBuilder GetOrCreateBuilder(IHostBuilder builder)
        {
            if (!Builders.TryGetValue(builder, out var conventionalBuilder))
            {
                var diagnosticSource          = new DiagnosticListener("Rocket.Surgery.Hosting");
                var dependencyContext         = DependencyContext.Default;
                var logger                    = new DiagnosticLogger(diagnosticSource);
                var serviceProviderDictionary = new ServiceProviderDictionary(builder.Properties);
                serviceProviderDictionary.Set <ILogger>(logger);
                var assemblyCandidateFinder = new DependencyContextAssemblyCandidateFinder(dependencyContext, logger);
                var assemblyProvider        = new DependencyContextAssemblyProvider(dependencyContext, logger);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, serviceProviderDictionary, logger);
                conventionalBuilder = new RocketHostBuilder(builder, scanner, assemblyCandidateFinder, assemblyProvider, diagnosticSource, serviceProviderDictionary);

                var host = new RocketContext(builder);
                builder
                .ConfigureHostConfiguration(host.CaptureArguments)
                .ConfigureHostConfiguration(host.ConfigureCli)
                .ConfigureAppConfiguration(host.ReplaceArguments)
                .ConfigureAppConfiguration(host.ConfigureAppConfiguration)
                .ConfigureServices(host.ConfigureServices)
                .ConfigureServices(host.DefaultServices);
                Builders.Add(builder, conventionalBuilder);
            }

            return(conventionalBuilder);
        }
예제 #6
0
        public static CoreDependencyInstances Setup(Microsoft.Extensions.Logging.ILogger functionsLogger = null)
        {
            var diagLogger = DiagnosticLogger.CreateInstance(functionsLogger);

            return(new CoreDependencyInstances
                   (
                       diagLogger,
                       new EnvironmentValueReader(diagLogger)
                   ));
        }
예제 #7
0
        internal static RocketWasmHostBuilder GetOrCreateBuilder(IWebAssemblyHostBuilder builder, Assembly assembly = null)
        {
            if (!Builders.TryGetValue(builder, out var conventionalBuilder))
            {
                var diagnosticSource          = new DiagnosticListener("Rocket.Surgery.Blazor");
                var logger                    = new DiagnosticLogger(diagnosticSource);
                var serviceProviderDictionary = new ServiceProviderDictionary(builder.Properties);

                serviceProviderDictionary.Set <ILogger>(logger);
                serviceProviderDictionary.Set(HostType.Live);
                var assemblyCandidateFinder = new AppDomainAssemblyCandidateFinder(AppDomain.CurrentDomain, logger);
                var assemblyProvider        = new DefaultAssemblyProvider(AppDomain.CurrentDomain.GetAssemblies().Concat(GetAllAssemblies(assembly !)).ToArray());
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RocketHostBuilder" /> class.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="scanner">The scanner.</param>
 /// <param name="assemblyCandidateFinder">The assembly candidate finder.</param>
 /// <param name="assemblyProvider">The assembly provider.</param>
 /// <param name="diagnosticSource">The diagnostic source.</param>
 /// <param name="serviceProperties">The service properties.</param>
 public RocketHostBuilder(
     IHostBuilder builder,
     IConventionScanner scanner,
     IAssemblyCandidateFinder assemblyCandidateFinder,
     IAssemblyProvider assemblyProvider,
     DiagnosticSource diagnosticSource,
     IServiceProviderDictionary serviceProperties
     ) : base(scanner, assemblyCandidateFinder, assemblyProvider, diagnosticSource, serviceProperties)
 {
     Builder = builder;
     Logger  = new DiagnosticLogger(diagnosticSource);
 }
예제 #9
0
        public void ShouldBeIgnored()
        {
            // Arrange
            var logStrategy = new Mock <ILogStrategy>();

            logStrategy.Setup(x => x.WriteMessage(It.IsAny <string>())).Verifiable();
            var infoLogger = new DiagnosticLogger().Init(LogLevel.Info, logStrategy.Object);

            // Act
            infoLogger.LogMessage(LogLevel.Fatal, "info");

            // Assert
            logStrategy.Verify(x => x.WriteMessage(It.IsAny <string>()), Times.Never);
        }
예제 #10
0
        private void LearnMoreHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            if (e.Uri == null)
            {
                return;
            }

            BrowserHelper.StartBrowser(e.Uri);
            e.Handled = true;

            if (!(sender is Hyperlink hyperlink))
            {
                return;
            }

            DiagnosticLogger.LogHyperlink(hyperlink.Name ?? "Preview", _id, HasDescription, _logIdVerbatimInTelemetry, e.Uri.AbsoluteUri);
        }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RocketFunctionHostBuilder"/> class.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="functionsAssembly">The functions assembly.</param>
 /// <param name="startupInstance">The startup instance.</param>
 /// <param name="environment">The environment.</param>
 /// <param name="scanner">The scanner.</param>
 /// <param name="assemblyCandidateFinder">The assembly candidate finder.</param>
 /// <param name="assemblyProvider">The assembly provider.</param>
 /// <param name="diagnosticSource">The diagnostic source.</param>
 /// <param name="serviceProviderDictionary">The service provider dictionary of values</param>
 public RocketFunctionHostBuilder(
     IWebJobsBuilder builder,
     Assembly functionsAssembly,
     object startupInstance,
     IRocketEnvironment environment,
     IConventionScanner scanner,
     IAssemblyCandidateFinder assemblyCandidateFinder,
     IAssemblyProvider assemblyProvider,
     DiagnosticSource diagnosticSource,
     IServiceProviderDictionary serviceProviderDictionary) : base(scanner, assemblyCandidateFinder, assemblyProvider, diagnosticSource, serviceProviderDictionary)
 {
     _startupInstance  = startupInstance;
     _environment      = environment ?? CreateEnvironment();
     _logger           = new DiagnosticLogger(DiagnosticSource);
     Builder           = builder;
     FunctionsAssembly = functionsAssembly;
 }
예제 #12
0
        private void LearnMoreHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            if (e.Uri == null)
            {
                return;
            }

            BrowserHelper.StartBrowser(_serviceProvider, e.Uri);
            e.Handled = true;

            var hyperlink = sender as Hyperlink;

            if (hyperlink == null)
            {
                return;
            }

            DiagnosticLogger.LogHyperlink(hyperlink.Name ?? "Preview", _errorId, HasDescription, _telemetry, e.Uri.AbsoluteUri);
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this));
            base.Initialize();

            var logger = new DiagnosticLogger("AttachToAnything");

            var optionsPage = (AttachTargetOptionPage)GetDialogPage(typeof(AttachTargetOptionPage));

            _controller = new AttachToAnythingController(this, (DTE)GetService(typeof(DTE)), optionsPage, new ProcessWaitSource(logger), logger);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null == menuCommandService)
            {
                return;
            }

            SetupAttachCommand(menuCommandService);
            SetupOptionsCommand(menuCommandService);
        }
예제 #14
0
        /// <summary>
        /// Fors the application domain.
        /// </summary>
        /// <param name="appDomain">The application domain.</param>
        /// <param name="diagnosticSource">The diagnostic source.</param>
        /// <returns>Func&lt;IHostBuilder, IRocketHostBuilder&gt;.</returns>
        public static Func <IHostBuilder, IRocketHostBuilder> ForAppDomain(
            AppDomain appDomain,
            DiagnosticSource diagnosticSource = null)
        {
            return(builder =>
            {
                var b = RocketHostExtensions.GetOrCreateBuilder(builder);
                if (diagnosticSource != null)
                {
                    b = b.With(diagnosticSource);
                }

                var logger = new DiagnosticLogger(b.DiagnosticSource);
                var assemblyCandidateFinder = new AppDomainAssemblyCandidateFinder(appDomain, logger);
                var assemblyProvider = new AppDomainAssemblyProvider(appDomain, logger);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, b.ServiceProperties, logger);
                return RocketHostExtensions.Swap(b, b
                                                 .With(assemblyCandidateFinder)
                                                 .With(assemblyProvider)
                                                 .With(scanner)
                                                 );
            });
        }
        public void LogCritical()
        {
            var adapter = AutoFake.Resolve <DiagnosticListenerLoggingAdapter>();
            var source  = new DiagnosticListener("Test");

            using (source.SubscribeWithAdapter(adapter))
            {
                var logger = new DiagnosticLogger(source);

                logger.LogCritical("test");

                A.CallTo(
                    () => Logger.Log(
                        LogLevel.Critical,
                        A <EventId> ._,
                        A <object> ._,
                        A <Exception> ._,
                        A <Func <object, Exception, string> > ._
                        )
                    )
                .MustHaveHappened();
            }
        }
예제 #16
0
        /// <summary>
        /// Fors the dependency context.
        /// </summary>
        /// <param name="dependencyContext">The dependency context.</param>
        /// <param name="diagnosticSource">The diagnostic source.</param>
        /// <returns>Func&lt;IWebJobsBuilder, System.Object, IRocketFunctionHostBuilder&gt;.</returns>
        public static Func <IWebJobsBuilder, object, IRocketFunctionHostBuilder> ForDependencyContext(
            DependencyContext dependencyContext,
            DiagnosticSource diagnosticSource = null)
        {
            return((builder, startupInstance) =>
            {
                var b = RocketHostExtensions.GetOrCreateBuilder(builder, startupInstance, null);
                if (diagnosticSource != null)
                {
                    b = b.With(diagnosticSource);
                }

                var logger = new DiagnosticLogger(b.DiagnosticSource);
                var assemblyCandidateFinder = new DependencyContextAssemblyCandidateFinder(dependencyContext, logger);
                var assemblyProvider = new DependencyContextAssemblyProvider(dependencyContext, logger);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, b.ServiceProperties, logger);
                return RocketHostExtensions.Swap(b, b
                                                 .With(assemblyCandidateFinder)
                                                 .With(assemblyProvider)
                                                 .With(scanner)
                                                 );
            });
        }
예제 #17
0
        /// <summary>
        /// Fors the assemblies.
        /// </summary>
        /// <param name="assemblies">The assemblies.</param>
        /// <param name="diagnosticSource">The diagnostic source.</param>
        /// <returns>Func&lt;IHostBuilder, IRocketHostBuilder&gt;.</returns>
        public static Func <IHostBuilder, IRocketHostBuilder> ForAssemblies(
            IEnumerable <Assembly> assemblies,
            DiagnosticSource diagnosticSource = null)
        {
            return(builder =>
            {
                var b = RocketHostExtensions.GetOrCreateBuilder(builder);
                if (diagnosticSource != null)
                {
                    b = b.With(diagnosticSource);
                }

                var logger = new DiagnosticLogger(b.DiagnosticSource);
                var enumerable = assemblies as Assembly[] ?? assemblies.ToArray();
                var assemblyCandidateFinder = new DefaultAssemblyCandidateFinder(enumerable, logger);
                var assemblyProvider = new DefaultAssemblyProvider(enumerable, logger);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, b.ServiceProperties, logger);
                return RocketHostExtensions.Swap(b, b
                                                 .With(assemblyCandidateFinder)
                                                 .With(assemblyProvider)
                                                 .With(scanner)
                                                 );
            });
        }
예제 #18
0
        private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            if (e.Uri == null)
            {
                return;
            }

            BrowserHelper.StartBrowser(e.Uri);
            e.Handled = true;

            if (!(sender is Hyperlink hyperlink))
            {
                return;
            }

            if (!(hyperlink.Tag is DiagnosticData item))
            {
                return;
            }

            var telemetry = item.CustomTags.Any(t => t == WellKnownDiagnosticTags.Telemetry);

            DiagnosticLogger.LogHyperlink("ErrorList", item.Id, item.Description != null, telemetry, e.Uri.AbsoluteUri);
        }
예제 #19
0
 public static void ClearLog()
 {
     _logger = new DiagnosticLogger();
 }
예제 #20
0
        /// <summary>
        /// Gets the or create builder.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns>RocketHostBuilder.</returns>
        internal static RocketHostBuilder GetOrCreateBuilder(IHostBuilder builder)
        {
            if (!Builders.TryGetValue(builder, out var conventionalBuilder))
            {
                var diagnosticSource          = new DiagnosticListener("Rocket.Surgery.Hosting");
                var dependencyContext         = DependencyContext.Default;
                var logger                    = new DiagnosticLogger(diagnosticSource);
                var serviceProviderDictionary = new ServiceProviderDictionary(builder.Properties);
                serviceProviderDictionary.Set <ILogger>(logger);
                serviceProviderDictionary.Set(HostType.Live);
                var assemblyCandidateFinder = new DependencyContextAssemblyCandidateFinder(dependencyContext, logger);
                var assemblyProvider        = new DependencyContextAssemblyProvider(dependencyContext, logger);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, serviceProviderDictionary, logger);
                conventionalBuilder = new RocketHostBuilder(
                    builder,
                    scanner,
                    assemblyCandidateFinder,
                    assemblyProvider,
                    diagnosticSource,
                    serviceProviderDictionary
                    );

                conventionalBuilder.Set(
                    new ConfigurationOptions
                {
                    ApplicationConfiguration =
                    {
                        b => b.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true),
                        b => b.AddYamlFile("appsettings.yml",  optional: true, reloadOnChange: true),
                        b => b.AddYamlFile("appsettings.yaml", optional: true, reloadOnChange: true),
                        b => b.AddIniFile("appsettings.ini",   optional: true, reloadOnChange: true)
                    },
                    EnvironmentConfiguration =
                    {
                        (b, environmentName) => b.AddJsonFile(
                            $"appsettings.{environmentName}.json",
                            optional: true,
                            reloadOnChange: true
                            ),
                        (b, environmentName) => b.AddYamlFile(
                            $"appsettings.{environmentName}.yml",
                            optional: true,
                            reloadOnChange: true
                            ),
                        (b, environmentName) => b.AddYamlFile(
                            $"appsettings.{environmentName}.yaml",
                            optional: true,
                            reloadOnChange: true
                            ),
                        (b, environmentName) => b.AddIniFile(
                            $"appsettings.{environmentName}.ini",
                            optional: true,
                            reloadOnChange: true
                            )
                    }
                }
                    );

                var host = new RocketContext(builder);
                builder
                .ConfigureHostConfiguration(host.ComposeHostingConvention)
                .ConfigureHostConfiguration(host.CaptureArguments)
                .ConfigureHostConfiguration(host.ConfigureCli)
                .ConfigureAppConfiguration(host.ReplaceArguments)
                .ConfigureAppConfiguration(host.ConfigureAppConfiguration)
                .ConfigureServices(host.ConfigureServices)
                .ConfigureServices(host.DefaultServices);
                Builders.Add(builder, conventionalBuilder);
            }

            return(conventionalBuilder);
        }
        internal void ModifyManifest(string basePath)
        {
            var manifestPath = GetManifestPath(basePath);

            if (!File.Exists(manifestPath))
            {
                throw new FileNotFoundException("Can't configure native Android SDK nor set auto-init:false.",
                                                manifestPath);
            }

            var disableAutoInit = false;
            var options         = _getOptions();

            if (options is null)
            {
                var logger = new UnityLogger(new SentryOptions(), _interceptor);
                logger.LogWarning("Couldn't load SentryOptions. Can't configure native Android SDK.");
                disableAutoInit = true;
            }
            else if (!options.IsValid())
            {
                options.DiagnosticLogger?.LogWarning(
                    "Failed to validate Sentry Options. Android native support will not be configured.");
                disableAutoInit = true;
            }
            else if (!options.AndroidNativeSupportEnabled)
            {
                options.DiagnosticLogger?.LogDebug("Android Native support disabled via options.");
                disableAutoInit = true;
            }

            var androidManifest = new AndroidManifest(manifestPath, options?.DiagnosticLogger);

            androidManifest.RemovePreviousConfigurations();

            if (disableAutoInit)
            {
                androidManifest.DisableSentryAndSave();
                return;
            }

            options !.DiagnosticLogger?.LogDebug("Configuring Sentry options on AndroidManifest: {0}", basePath);

            options.DiagnosticLogger?.LogDebug("Setting DSN: {0}", options.Dsn);
            androidManifest.SetDsn(options.Dsn !);
            if (!options.DebugOnlyInEditor)
            {
                options.DiagnosticLogger?.LogDebug("Setting Debug: {0}", options.Debug);
                androidManifest.SetDebug(options.Debug);
            }
            else
            {
                options.DiagnosticLogger?.LogDebug("Not setting debug flag because DebugOnlyInEditor is true");
            }

            if (options.Release is not null)
            {
                options.DiagnosticLogger?.LogDebug("Setting Release: {0}", options.Release);
                androidManifest.SetRelease(options.Release);
            }

            if (options.Environment is not null)
            {
                options.DiagnosticLogger?.LogDebug("Setting Environment: {0}", options.Environment);
                androidManifest.SetEnvironment(options.Environment);
            }

            options.DiagnosticLogger?.LogDebug("Setting DiagnosticLevel: {0}", options.DiagnosticLevel);
            androidManifest.SetLevel(options.DiagnosticLevel);

            if (options.SampleRate.HasValue)
            {
                options.DiagnosticLogger?.LogDebug("Setting SampleRate: {0}", options.SampleRate);
                androidManifest.SetSampleRate(options.SampleRate.Value);
            }

            // TODO: Missing on AndroidManifest
            // options.DiagnosticLogger?.LogDebug("Setting MaxBreadcrumbs: {0}", options.MaxBreadcrumbs);
            // androidManifest.SetMaxBreadcrumbs(options.MaxBreadcrumbs);
            // options.DiagnosticLogger?.LogDebug("Setting MaxCacheItems: {0}", options.MaxCacheItems);
            // androidManifest.SetMaxCacheItems(options.MaxCacheItems);
            // options.DiagnosticLogger?.LogDebug("Setting SendDefaultPii: {0}", options.SendDefaultPii);
            // // androidManifest.SetSendDefaultPii(options.SendDefaultPii);

            // Disabling the native in favor of the C# layer for now
            androidManifest.SetAutoSessionTracking(false);
            // TODO: We need an opt-out for this:
            androidManifest.SetNdkScopeSync(true);

            // TODO: All SentryOptions and create specific Android options

            _ = androidManifest.Save();
        }
예제 #22
0
        /// <summary>
        /// Gets the or create builder.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="startupInstance">The startup instance.</param>
        /// <param name="environment">The environment.</param>
        /// <returns>RocketFunctionHostBuilder.</returns>
        internal static RocketFunctionHostBuilder GetOrCreateBuilder(
            IWebJobsBuilder builder,
            object startupInstance,
            IRocketEnvironment?environment
            )
        {
            if (!Builders.TryGetValue(builder, out var conventionalBuilder))
            {
                var diagnosticSource  = new DiagnosticListener("Rocket.Surgery.Hosting");
                var functionsAssembly = startupInstance.GetType().Assembly;

                var location = Path.GetDirectoryName(functionsAssembly.Location);
                DependencyContext?dependencyContext = null;
                while (!string.IsNullOrEmpty(location))
                {
                    var depsFilePath = Path.Combine(location, functionsAssembly.GetName().Name + ".deps.json");
                    if (File.Exists(depsFilePath))
                    {
                        using var stream  = File.Open(depsFilePath, FileMode.Open, FileAccess.Read);
                        using var reader  = new DependencyContextJsonReader();
                        dependencyContext = reader.Read(stream);
                        break;
                    }

                    location = Path.GetDirectoryName(location);
                }

                var logger = new DiagnosticLogger(diagnosticSource);
                var assemblyCandidateFinder = new DependencyContextAssemblyCandidateFinder(dependencyContext !, logger);
                var assemblyProvider        = new DependencyContextAssemblyProvider(dependencyContext !, logger);
                var properties = new ServiceProviderDictionary();
                properties.Set <ILogger>(logger);
                properties.Set(HostType.Live);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, properties, logger);
                conventionalBuilder = new RocketFunctionHostBuilder(
                    builder,
                    functionsAssembly,
                    startupInstance,
                    environment !,
                    scanner,
                    assemblyCandidateFinder,
                    assemblyProvider,
                    diagnosticSource,
                    properties
                    );
                conventionalBuilder.Set(
                    new ConfigurationOptions
                {
                    ApplicationConfiguration =
                    {
                        b => b.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true),
                        b => b.AddYamlFile("appsettings.yml",  optional: true, reloadOnChange: true),
                        b => b.AddYamlFile("appsettings.yaml", optional: true, reloadOnChange: true),
                        b => b.AddIniFile("appsettings.ini",   optional: true, reloadOnChange: true)
                    },
                    EnvironmentConfiguration =
                    {
                        (b, environmentName) => b.AddJsonFile(
                            $"appsettings.{environmentName}.json",
                            optional: true,
                            reloadOnChange: true
                            ),
                        (b, environmentName) => b.AddYamlFile(
                            $"appsettings.{environmentName}.yml",
                            optional: true,
                            reloadOnChange: true
                            ),
                        (b, environmentName) => b.AddYamlFile(
                            $"appsettings.{environmentName}.yaml",
                            optional: true,
                            reloadOnChange: true
                            ),
                        (b, environmentName) => b.AddIniFile(
                            $"appsettings.{environmentName}.ini",
                            optional: true,
                            reloadOnChange: true
                            )
                    }
                }
                    );
                Builders.Add(builder, conventionalBuilder);
            }

            return(conventionalBuilder);
        }