Visual Studio Tools
This section contains information on how to use the Visual Studio tools for developing bots with DisCatSharp.
Analyzers & Code Fixes
DisCatSharp can be extended with a set of analyzers that can help you write better code. These analyzers will warn you about common mistakes and bad practices.
DisCatSharp Analyzer
Installation
To use the DisCatSharp Analyzer, you need to install the DisCatSharp.Analyzer NuGet package.
The NuGet package is the supported delivery model for analyzers and code fixes.
If you maintain the analyzer/tooling stack, see the authoring guide.
Visual Studio Code
Enable omnisharp.enableRoslynAnalyzers in your settings.
JetBrains Rider
See https://www.jetbrains.com/help/rider/Settings_Roslyn_Analyzers.html
Included Rules
Diagnostic Families
The analyzer currently contains a mix of legacy shipped IDs and newer family-based ranges.
Use this as the quick orientation guide.
DisCatSharp.Attributes Based Analyzers
These analyzers check for the presence of attributes from the DisCatSharp.Attributes namespace and report diagnostics based on their usage.
| Rule ID | Category | Severity | Notes |
|---|---|---|---|
| DCS0001 | Usage | Info | Experimental Attribute Analyzer |
| DCS0002 | Usage | Error | Deprecated Attribute Analyzer |
| DCS0101 | Usage | Warning | DiscordInExperiment Attribute Analyzer |
| DCS0102 | Usage | Error | DiscordDeprecated Attribute Analyzer |
| DCS0103 | Usage | Warning | DiscordUnreleased Attribute Analyzer |
| DCS0200 | Usage | Info | RequiresFeature Attribute Analyzer |
| DCS0201 | Usage | Warning | RequiresOverride Attribute Analyzer |
Reserved families
| Family | Purpose |
|---|---|
DCS0XXX |
DisCatSharp.Attributes based diagnostics |
DCS1XXX |
Core DisCatSharp diagnostics, migrations, and cross-cutting code fixes |
DCS2XXX |
DisCatSharp.ApplicationCommands diagnostics and code-fix families |
DCS3XXX |
DisCatSharp.CommandsNext diagnostics and code-fix families |
DCS4XXX |
DisCatSharp.Interactivity diagnostics and code-fix families |
DCS5XXX |
DisCatSharp.Voice diagnostics and code-fix families |
DCS6XXX |
DisCatSharp.Lavalink diagnostics and code-fix families |
DCS7XXX |
DisCatSharp.Common diagnostics and code-fix families |
DCS8XXX |
Hosting, dependency injection, and configuration diagnostics and code-fix families |
DCS9XXX |
Reserved |
Core family
| Rule ID | Category | Severity | Notes |
|---|---|---|---|
| DCS1101 | Usage | Removed — superseded by DCS1103 | |
| DCS1102 | Usage | Warning | deleteMessageDays renamed to deleteMessageSeconds on ban methods; named-argument callers auto-fixed |
| DCS1103 | Usage | Error | DiscordClient.Presences property removed; use GetPresences(userId), guild.Presences, or CurrentPresence |
| DCS1201 | Usage | Warning | Config property migration analyzer and code fix for DiscordConfiguration (legacy properties moved to nested sub-configurations) |
| DCS1301 | Usage | Warning | using should be await using on DisCatSharp client types that implement IAsyncDisposable |
| DCS1302 | Usage | Warning | .Dispose() should be await .DisposeAsync() on DisCatSharp client types that implement IAsyncDisposable |
Application command family
| Rule ID | Category | Severity | Notes |
|---|---|---|---|
| DCS2101 | Usage | Info | Application command checks-failed migration prototype |