FSharp.Interop.Dlr.Analyzers 1.0.0-rc.2

This is a prerelease version of FSharp.Interop.Dlr.Analyzers.
dotnet add package FSharp.Interop.Dlr.Analyzers --version 1.0.0-rc.2
                    
NuGet\Install-Package FSharp.Interop.Dlr.Analyzers -Version 1.0.0-rc.2
                    
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="FSharp.Interop.Dlr.Analyzers" Version="1.0.0-rc.2">
  <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="FSharp.Interop.Dlr.Analyzers" Version="1.0.0-rc.2" />
                    
Directory.Packages.props
<PackageReference Include="FSharp.Interop.Dlr.Analyzers">
  <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 FSharp.Interop.Dlr.Analyzers --version 1.0.0-rc.2
                    
#r "nuget: FSharp.Interop.Dlr.Analyzers, 1.0.0-rc.2"
                    
#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.
#:package FSharp.Interop.Dlr.Analyzers@1.0.0-rc.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FSharp.Interop.Dlr.Analyzers&version=1.0.0-rc.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FSharp.Interop.Dlr.Analyzers&version=1.0.0-rc.2&prerelease
                    
Install as a Cake Tool

FSharp.Interop.Dlr.Analyzers

Build-time checks for FSharp.Interop.Dlr. A dlr { } block needs [<ReflectedDefinition>] on the function or member that contains it (or on an enclosing module or type), and without it the first call raises; this analyzer reports that at build time, and in Ionide, with a fix that adds the attribute to the outermost binding containing the block, i.e. the function or member the compiler stores a definition for (a local function inside it is a closure and cannot carry the attribute). A block in module-level do code is reported without a fix: move it into a function.

Code Severity Reports
DLR001 Error a dlr { } with no [<ReflectedDefinition>] on its enclosing function/member, module or type
DLR002 Error a ? operator or Dlr.* marker used outside any dlr { } (it is only ever quoted; executed, it throws InvalidOperationException)
DLR003 Error two or more dlr { } blocks starting on one source line (a block is found by the line of its Run call; the first call raises DlrTranslationException)
DLR004 Error a dlr { } inside an inline function or member (declaration-level or a local let inline): in Release the function is expanded into every caller, where the block's captured values are inlined away and its body is not where the reflected definition says — a Debug build calls it as a method, so it only appears to work there; remove inline or move the block out. A block DLR004 refuses gets no DLR001
DLR005 Error a marker out of place inside a block — each a DlrTranslationException at the block's first call; the cases are listed below the table
DLR006 Error a dlr { } in a function or member whose reflected definition FSharp.Core will not decode — it holds typeof<System.Void> — so every block in it fails at run time with the not-found error naming the member

DLR005 reports: an argument marker — Dlr.named, Dlr.namedOf, Dlr.argsOf, Dlr.typeArgs, Dlr.typeArgsOf, Dlr.out, Dlr.outAs, Dlr.ref — anywhere but as an argument of a call (a member call, Dlr.invoke, Dlr.call / Dlr.apply, Dlr.new'); Dlr.typeArgs / typeArgsOf not first, or on Dlr.call / Dlr.apply / Dlr.new' (a value or constructor call takes none); Dlr.namedOf or Dlr.argsOf twice in one call; a positional argument after Dlr.namedOf; Dlr.named on a record in a variable rather than the literal (names from data are Dlr.namedOf); Dlr.Static<T>.Overloads anywhere but as the target of a call; Dlr.call x read at a non-function type; Dlr.ref on anything but a let mutable; a call with Dlr.out whose result type does not fit (the return value then each out as a tuple, the outs alone, or the one out's value, the first agreeing with every type Dlr.outAs states); Dlr.out in Dlr.new' (its result is the T; a constructor's ref is Dlr.ref); Dlr.out / Dlr.ref in a call with Dlr.namedOf / Dlr.argsOf.

Setup

An FSharp.Analyzers.SDK analyzer runs in the fsharp-analyzers tool, and only in the tool of the exact SDK version it was built against: fsharp-analyzers 0.39.2, which needs .NET SDK 10 (8 and 9 are not supported). The build is in analyzers/dotnet/fs/net10.0.

The project being analyzed can target anything, net472 included; only the SDK you build with matters.

  1. The tool, in a manifest so every clone and CI gets the same one:

    dotnet new tool-manifest            # if there is no .config/dotnet-tools.json yet
    dotnet tool install fsharp-analyzers --version 0.39.2
    

    (dotnet tool restore on a fresh clone.)

  2. In the project:

    <PackageReference Include="FSharp.Analyzers.Build" Version="0.5.0" PrivateAssets="all" />
    <PackageReference Include="FSharp.Interop.Dlr.Analyzers" Version="*" GeneratePathProperty="true" PrivateAssets="all" />
    
    <PropertyGroup>
    
      <RunAnalyzers>true</RunAnalyzers>
      <FSharpAnalyzersOtherFlags>--analyzers-path "$(PkgFSharp_Interop_Dlr_Analyzers)/analyzers/dotnet/fs/net10.0"</FSharpAnalyzersOtherFlags>
    
      <FSharpAnalyzersContinueOnError>false</FSharpAnalyzersContinueOnError>
    </PropertyGroup>
    

    The net10.0 folder, not the package root: the tool looks for analyzers in the directory it is given.

  3. Check it actually runs: a clean build prints nothing, so remove one [<ReflectedDefinition>] and build — you should see error DLR001: dlr { } needs [<ReflectedDefinition>] …. If not, the usual causes are the tool not restored (dotnet-fsharp-analyzers does not exist), RunAnalyzers missing, or GeneratePathProperty missing so the path is empty.

Ionide picks the analyzer up from the same path; Rider and Visual Studio do not run SDK analyzers, so there the check happens at build. -p:RunAnalyzers=false skips it.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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
1.0.0-rc.2 54 10/6/2026
1.0.0-rc.1 60 10/6/2026