DisCatSharp Analyzer Rule DCS1201
This rule identifies accesses to deprecated forwarding properties on DiscordConfiguration that have been migrated to nested sub-configurations.
The new configuration architecture groups related settings under dedicated objects:
Api— API version, channel, locale, timezone, overrideGateway— reconnect, sharding, compression, capabilitiesRest— timeout, ratelimiting, proxyCache— message/presence cache sizes, auto-refresh, SKULogging— log level, timestamp format, logger factoryDiagnostics— payload events, update checks (nested:Diagnostics.UpdateChecks)Telemetry— Sentry, error tracking, scrubber, developer mode
What the code fix handles
The code fix supports two usage patterns:
Direct property access
For code like config.ApiChannel or config.DisableUpdateCheck, the single-property fix rewrites the member access to the nested path:
config.ApiChannel→config.Api.Channelconfig.HttpTimeout→config.Rest.RequestTimeoutconfig.DisableUpdateCheck→config.Diagnostics.UpdateChecks.Disabled
Object initializer assignments
For code using object initializer syntax:
var cfg = new DiscordConfiguration
{
ApiChannel = ApiChannel.Canary,
AutoReconnect = true,
HttpTimeout = TimeSpan.FromMinutes(1),
DisableUpdateCheck = false,
EnableSentry = true,
};
Two code actions are offered:
- "Use Api.Channel instead" — rewrites a single property to its nested initializer form
- "Migrate all configuration properties in this initializer" — rewrites the entire initializer at once, grouping properties by their config section
The batch fix produces:
var cfg = new DiscordConfiguration
{
Api =
{
Channel = ApiChannel.Canary,
},
Gateway =
{
AutoReconnect = true,
},
Rest =
{
RequestTimeout = TimeSpan.FromMinutes(1),
},
Diagnostics =
{
UpdateChecks =
{
Disabled = false,
},
},
Telemetry =
{
EnableSentry = true,
},
};
Properties that were not migrated (root keepers like Token, TokenType, Intents, ServiceProvider) are preserved as-is in the output.
Both the new DiscordConfiguration { ... } and the target-typed new() { ... } forms are supported.
What it does not rewrite
The code fix does not handle:
- Properties accessed through intermediate variables or method chains beyond simple member access
- Dynamic or reflection-based property access
- Configuration set through
IConfigurationbinding or hosting extensions (those read from the nested structure automatically)
Why this rule exists
DiscordConfiguration was restructured from a flat class with 40+ properties into a hierarchy of focused sub-configurations. The old flat properties remain as deprecated forwarding shims to ease migration, but they will be removed in a future release.
This diagnostic surfaces each outdated property access with a one-click fix so consumers can migrate incrementally or all at once.