CustomCode.Analyzer 0.1.4

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CustomCode.Analyzer" Version="0.1.4">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CustomCode.Analyzer" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="CustomCode.Analyzer">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CustomCode.Analyzer --version 0.1.4
                    
#r "nuget: CustomCode.Analyzer, 0.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=CustomCode.Analyzer&version=0.1.4
                    
Install CustomCode.Analyzer as a Cake Addin
#tool nuget:?package=CustomCode.Analyzer&version=0.1.4
                    
Install CustomCode.Analyzer as a Cake Tool

OutSystems Developer Cloud (ODC) Custom Code Analyzer

Coverage Lines of Code PRs Welcome

Reliability Rating Maintainability Rating Vulnerabilities

ℹ️ This component is unofficial and unsupported by OutSystems.

Screenshot of Visual Studio Code displaying C# code with highlighted errors in the Problems panel, showing naming and mapping rule violations detected by a the ODC Custom Code Analyzer.

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:

  1. 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.

  2. 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 a ConcurrentDictionary of interface declarations and validating their uniqueness (NoSingleInterfaceRule or ManyInterfacesRule). 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:

  1. Select Tools > Options.
  2. From the left menu select C# > Advanced.
  3. Set both Run background code analysis for and Show compiler errors and warnings to Entire solution.
  4. 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:

  1. Open the command palette (Ctrl+Shift+P).
  2. 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.

There are no supported framework assets in this package.

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.

Version Downloads Last updated
0.2.1 139 2/23/2025
0.2.0 297 1/13/2025
0.1.4 82 1/9/2025
0.1.3 94 1/6/2025
0.1.2 121 1/4/2025
0.1.1 103 1/2/2025
0.1.0 124 12/31/2024