AppSurface Search
API Reference

Defaults

Type

DefaultEnvironmentProvider

Source

Default implementation of IEnvironmentProvider that retrieves the environment from command-line host arguments or system environment variables. Command-line --environment wins when supplied, otherwise it checks for "ASPNETCORE_ENVIRONMENT" first, then "DOTNET_ENVIRONMENT", and defaults to "Production" if neither is set. Can be overridden by passing a custom implementation to the StartupContext , when building the host.

Method

GetEnvironmentVariable

string? GetEnvironmentVariable(string name, string? defaultValue = null)

Gets the value of an environment variable from the system.

Parameters

  • name
    The exact environment variable name to query.
  • defaultValue
    The default value to return if the environment variable is unset.

Returns

The environment variable value, an empty string when explicitly set empty, or the provided default if the variable is unset.

Remarks

Use GetEnvironmentVariable when callers need the provider's centralized lookup and unset-value defaulting behavior. Use Environment or IsDevelopment for the active application environment, and prefer direct System.Environment access only for low-level infrastructure code. Passing a null or empty name follows System.Environment.GetEnvironmentVariable(string) semantics. Do not log returned values unless the variable is known to be non-sensitive, and do not trim or alter casing unless the caller intentionally wants to change the platform-specific value.

Method

ResolveEnvironmentArgument

string? ResolveEnvironmentArgument(IReadOnlyList<string> args)

Resolves the effective command-line environment value from host arguments.

Parameters

  • args
    Command-line arguments supplied to the host startup pipeline.

Returns

The last valid command-line environment value, or null when none is supplied.

Remarks

Recognizes split and inline forms such as --environment Development and --environment=Development . Blank, switch-like, or assignment-shaped split values are ignored, and the last valid command-line value wins to match Microsoft configuration duplicate-key behavior. Returns null when the arguments do not contain a valid command-line environment value.

Property

Environment

string Environment { get; } Source

The current environment name. Read from command-line --environment , "ASPNETCORE_ENVIRONMENT", or "DOTNET_ENVIRONMENT"; defaults to "Production" if none is set.

Property

IsDevelopment

bool IsDevelopment { get; } Source

True if the current environment is "Development".

Type

NoHostModule

Source

A basic implementation of IAppSurfaceHostModule that does nothing. This is useful for providing implementations of apps that do not require a module.

Remarks

Use NoHostModule only when no part of the application expects module-provided services, dependency registrations, middleware, endpoints, or host configuration. It is safe for minimal hosts that rely entirely on framework defaults. Create a real IAppSurfaceHostModule when the app needs service registration, dependency wiring, or host lifecycle hooks.

Method

ConfigureServices

void ConfigureServices(StartupContext context, IServiceCollection services)

Configures services for the module. This implementation is empty.

Parameters

  • context
    The startup context.
  • services
    The service collection.

Remarks

No services are added. Callers that expect module-owned services must not use NoHostModule .

Method

RegisterDependentModules

void RegisterDependentModules(ModuleDependencyBuilder builder)

Registers dependent modules. This implementation is empty.

Parameters

  • builder
    The module dependency builder.

Remarks

No dependencies are declared. Create a concrete module when startup ordering or dependency modules matter.

Method

ConfigureHostBeforeServices

void ConfigureHostBeforeServices(StartupContext context, IHostBuilder builder)

Configures the host before services are registered. This implementation is empty.

Parameters

  • context
    The startup context.
  • builder
    The host builder.

Remarks

No host configuration is applied before service registration.

Method

ConfigureHostAfterServices

void ConfigureHostAfterServices(StartupContext context, IHostBuilder builder)

Configures the host after services are registered. This implementation is empty.

Parameters

  • context
    The startup context.
  • builder
    The host builder.

Remarks

No host configuration is applied after service registration.

Type

InternalServicesModule

Source

Internal Services Registration