Roslyn Compiler Platform

repository·main·Indexed 12 days ago

https://github.com/dotnet/roslyn

Open-source implementation of the C# and Visual Basic compilers. It provides a rich API surface for building advanced code analysis tools, IDE features, and compilers. Includes documentation on compiler specifications, breaking changes across .NET and Visual Studio versions, and specialized analyzer packages like Microsoft.CodeAnalysis.BannedApiAnalyzers and Microsoft.CodeAnalysis.PublicApiAnalyzers.

Tokens
185.3K
Snippets
375
Records
742
Agent score
98%

What's inside Roslyn

  1. Overview of Compiler Toolset NuGet Packages

    main
    The Roslyn compiler provides Toolset NuGet packages that allow developers to override the default Roslyn compiler provided by MSBuild or the .NET SDK. Installing these packages instructs the MSBuild engine to use the version of the Roslyn build tasks and compilers contained within the package instead of the locally installed ones.
  2. Overview of dotnet-roslyn-manifest-generator

    main
    The dotnet-roslyn-manifest-generator is a tool used within the Roslyn ecosystem, specifically related to the Terrapin compiler infrastructure. It is responsible for generating artifacts manifests, which are used to track and manage build artifacts in the Terrapin environment.
  3. What is the Syntax API?

    main

    The Syntax API provides access to the exact same parsers, data structures, and algorithms used by the Visual Basic and C# compilers. It allows developers to analyze, reason about, and construct syntax trees that represent code with full fidelity.

    Key characteristics include:

    • Full Fidelity: Every bit of information, including whitespace and comments, is represented.
    • Immutability: Syntax trees cannot be changed once created, making them inherently thread-safe for concurrent analysis.
  4. Overview of Incremental Generators

    main

    Incremental generators are a high-performance API designed to replace the original ISourceGenerator (v1 source generators). They allow developers to define fine-grained generation strategies that the hosting layer (like Visual Studio) can execute efficiently by exploiting caching between steps.

    Key benefits include:

    • Scalability: Designed to support massive projects at the scale of Roslyn/CoreCLR.
    • Performance: Uses a pipeline-based approach to reduce duplicate work through caching.
    • Extensibility: Supports generating items beyond just source text.
    • Compatibility: Can coexist with existing ISourceGenerator implementations.
  5. Understand the Roslyn testing categories

    main

    Roslyn testing is categorized into three main types depending on the development lifecycle stage:

    1. Routine Product Testing: Focuses on features marked with the :mag: tag. These are scenarios regularly tested against internal builds.
    2. Release Testing: Involves testing all product features across all supported languages.
    3. New Language Feature Testing: A multi-phase process for evaluating new language syntax or rules.

    New Language Feature Testing Phases

    • Merge Signoff: Determines if a feature is ready to be merged. Critical IDE features in Typing, Navigating, and Viewing (marked with :fast_forward:) must function correctly. Any non-trivial issues in these areas are considered merge-blocking. All features must be free of crashes, asserts, and hangs.
    • Feature Signoff: Per-feature signoff that includes links to any remaining non-blocking issues.
    • Feature Suggestions: Brainstorming enhancements to make the new language feature more delightful for users.
  6. Identify banned APIs with Microsoft.CodeAnalysis.BannedApiAnalyzers

    main
    The Microsoft.CodeAnalysis.BannedApiAnalyzers package provides customizable rules to identify and flag references to specific APIs that have been banned in your codebase. This is useful for enforcing architectural constraints or preventing the use of deprecated/unsafe methods.
  7. Monitor public API changes with Microsoft.CodeAnalysis.PublicApiAnalyzers

    main
    The Microsoft.CodeAnalysis.PublicApiAnalyzers package is designed for library authors. It provides rules to help monitor and detect changes to public APIs, ensuring that breaking changes are caught during the development process.
  8. Use Replay to profile compiler performance

    main

    Replay is a tool designed to replay compilation events from an MSBuild binary log directly into the compiler server. This process removes MSBuild overhead from the logs, providing a cleaner view of compiler performance. It is also useful for comparing performance changes between different code branches by running the same binary log against both.

    dotnet run --framework net472 --configuration Release <path-to-binlog>