public void AdditionalTests(IWebHostBuilder webHostBuilder, IServiceCollection serviceDescriptors)
        {
            var factory = new MyLoggerFactory();

//                        ^^^^^^^^^^^^^^^^^^^^^
            new MyLoggerFactory("data"); // Noncompliant

            // Calling extension methods as static methods
            WebHostBuilderExtensions.ConfigureLogging(webHostBuilder, (Action <ILoggingBuilder>)null);         // Noncompliant
            LoggingServiceCollectionExtensions.AddLogging(serviceDescriptors, (Action <ILoggingBuilder>)null); // Noncompliant

            AzureAppServicesLoggerFactoryExtensions.AddAzureWebAppDiagnostics(factory, null);                  // Noncompliant
            ConsoleLoggerExtensions.AddConsole(factory);                                                       // Noncompliant
            DebugLoggerFactoryExtensions.AddDebug(factory);                                                    // Noncompliant
            EventLoggerFactoryExtensions.AddEventLog(factory);                                                 // Noncompliant
            EventSourceLoggerFactoryExtensions.AddEventSourceLogger(factory);                                  // Noncompliant
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
            });

            services.AddSingleton <ILightsRepo, LightsRepo>();
            services.AddSingleton <IKitchenRepo, KitchenRepo>();
            services.AddSingleton <List <Microcontroller> >(mcus);
            services.AddSingleton <Daemon, Kitchen>();
            services.AddSingleton <Daemon, Lights>();
            services.AddSignalR().AddJsonProtocol(options => options.PayloadSerializerOptions.WriteIndented = true);

#if CORS_ENABLED
            services.AddCors(options => options.AddPolicy("CorsPolicy",
                                                          builder =>
            {
                builder.AllowAnyMethod()
                .AllowAnyHeader()
                .WithOrigins(ConnectionExtension.LocalIP)
                .AllowCredentials();
            }));
#endif

#if LOGGING_ENABLED
            services.AddLogging(builder =>
            {
                builder.AddConsole().AddDebug();
                DebugLoggerFactoryExtensions.AddDebug(builder).AddConsole();
            });
#endif

            services.AddRazorPages();
        }