CustomCode.Analyzer
0.1.4
See the version list below for details.
dotnet add package CustomCode.Analyzer --version 0.1.4
NuGet\Install-Package CustomCode.Analyzer -Version 0.1.4
<PackageReference Include="CustomCode.Analyzer" Version="0.1.4"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="CustomCode.Analyzer" Version="0.1.4" />
<PackageReference Include="CustomCode.Analyzer"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add CustomCode.Analyzer --version 0.1.4
#r "nuget: CustomCode.Analyzer, 0.1.4"
#addin nuget:?package=CustomCode.Analyzer&version=0.1.4
#tool nuget:?package=CustomCode.Analyzer&version=0.1.4
OutSystems Developer Cloud (ODC) Custom Code Analyzer
ℹ️ This component is unofficial and unsupported by OutSystems.
Overview
When you want to extend your ODC apps with custom C# code, you do so with the External Libraries SDK. This SDK allows you to write C# code that you can call from your ODC apps.
Although IntelliSense in your IDE guides the available SDK decorators and their syntax, it does not guide the rules you must follow (for example, on naming and design decisions). This guidance is provided when uploading your project's built assembly to the ODC Portal, where you get feedback on rule violations. Using this component brings that feedback forward and gives you real-time feedback on compliance with the rules as you write the code. You also get real-time guidance on best practices.
Technical Primer
When you upload your project's built assembly to the ODC Portal, it does not have access to the underlying code—the ODC Portal checks compliance with the rules by reflecting on the assembly's metadata.
This component, built from scratch, implements the rules using the rich code analysis APIs of Roslyn, the .NET compiler.
Analyzer phases
The analyzer operates in two distinct phases, registered through the Roslyn AnalysisContext
:
Symbol analysis phase – Triggered by
RegisterSymbolAction
, this phase performs immediate syntax and semantic analysis on individual declarations as you type. For example, when you declare a method, the analyzer instantly checks if its name starts with an underscore and reports a violation if it does (NameBeginsWithUnderscoresRule
). These diagnostics appear immediately in your IDE's Problems window.Compilation end phase – Registered via
RegisterCompilationEndAction
, this phase runs after all symbols have been processed and the semantic model is complete. For example, it ensures exactly one[OSInterface]
exists across your entire codebase by maintaining aConcurrentDictionary
of interface declarations and validating their uniqueness (NoSingleInterfaceRule
orManyInterfacesRule
). These diagnostics may appear with a slight delay as they require complete semantic analysis.
How to use
Visual Studio 2022 (Enterprise, Pro and Community editions)
You can use the auto-updating extension from the Visual Studio Marketplace. Simply install the extension from the Visual Studio Marketplace.
If your project references the External Libraries SDK (OutSystems.ExternalLibraries.SDK
), the extension should automatically start providing feedback on your code.
To ensure real-time feedback for compilation end phase rules (not just during builds), you need to configure your Visual Studio's background analysis:
- Select Tools > Options.
- From the left menu select C# > Advanced.
- Set both Run background code analysis for and Show compiler errors and warnings to Entire solution.
- Make sure the Run code analysis in separate process box is unchecked.
Others
Add the NuGet package as a dev dependency to your ODC external libraries project:
dotnet add package CustomCode.Analyzer
If your project references the External Libraries SDK (OutSystems.ExternalLibraries.SDK
), the package should automatically start providing feedback on your code.
Visual Studio Code
To ensure real-time feedback for compilation end phase rules (not just during builds), you need to configure your Visual Studio Code's background analysis:
- Open the command palette (Ctrl+Shift+P).
- Search for "roslyn". Set the Dotnet › Background Analysis: Analyzer Diagnostics Scope to fullSolution.
💡 Auto-updating extensions for Visual Studio Code and Rider are in the works.
TODO
See here.
Contributing
Please report bugs and feature requests here.
PRs are welcome. Code quality improvements, new features (especially those unassigned and listed here) and documentation improvements are all welcome 🤗 All changes to Analyzer code should pass all existing tests (dotnet test
) and all new features should be covered by new tests.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.