ILNumerics.Community.Analyzers
7.2.0.18
dotnet add package ILNumerics.Community.Analyzers --version 7.2.0.18
NuGet\Install-Package ILNumerics.Community.Analyzers -Version 7.2.0.18
<PackageReference Include="ILNumerics.Community.Analyzers" Version="7.2.0.18" />
<PackageVersion Include="ILNumerics.Community.Analyzers" Version="7.2.0.18" />
<PackageReference Include="ILNumerics.Community.Analyzers" />
paket add ILNumerics.Community.Analyzers --version 7.2.0.18
#r "nuget: ILNumerics.Community.Analyzers, 7.2.0.18"
#:package ILNumerics.Community.Analyzers@7.2.0.18
#addin nuget:?package=ILNumerics.Community.Analyzers&version=7.2.0.18
#tool nuget:?package=ILNumerics.Community.Analyzers&version=7.2.0.18
Analyzers
A set of Roslyn analyzers and code fixes to enforce ILNumerics (http://ilnumerics.net/) function & memory rules (see https://ilnumerics.net/FunctionRules.html).
ILNumerics function rules ensure that APIs using ILNumerics arrays clearly separate inputs, outputs, and locals, and that signatures communicate this intent explicitly. Inputs are passed as InArray<T>, outputs as OutArray<T>, and return values as RetArray<T>. Regular Array<T> is reserved for local (or class level) variables. This avoids accidental reuse of result buffers, prevents hidden allocations, and makes data flow and lifetime of ILNumerics arrays obvious and analyzable.
Getting started
Install the NuGet package ILNumerics.Community.Analyzers into any project that should be analyzed:
dotnet add package ILNumerics.Community.Analyzers
- The package contains both analyzers and code fixes.
- Visual Studio and other supported IDEs will run them during typing (live analysis) and on build.
Rules
ILN0001 — Don't use
varfor (local) ILNumerics arraysImplicit typing is forbidden for ILNumerics arrays (
Array<T>,InArray<T>,OutArray<T>,RetArray<T>,Logical,Cell, etc.). Use explicit types so readers (and the analyzer) can see whether a variable is an input, output, return buffer, or localArray<T>. This prevents subtle bugs where aRetArray<T>is reused in unexpected ways.ILN0002 — Only
In/Out/Retin signatures (not in bodies/fields/props)InArray<T>,OutArray<T>, andRetArray<T>are meant purely as API "flavors" for parameters and return types. They must not appear as locals, fields, or general properties. Exceptions are very constrained: get‑onlyRet*properties, set‑only or init‑onlyIn*properties are allowed as configuration‑style surfaces, but all other uses in the object model or locals are flagged.ILN0003 — Function signatures should use ILNumerics flavors (in/out parameter and returns)
Public/internal methods that expose ILNumerics arrays should not use plain
Array<T>in signatures. Parameters should beInArray<T>/OutArray<T>and return values should beRetArray<T>. This documents the function contract (who owns the buffer, who may modify it) and enables the runtime and analyzers to enforce correct reuse and memory behavior.ILN0004 — Avoid C#
out/refwith ILNumerics arrays (useOutArray<T>)ILNumerics discourages C#
ref/outparameters for its array types. Instead ofref Array<T>orout Array<T>, APIs should useOutArray<T>(or the appropriate flavor) and pass arrays in the ILNumerics way. This keeps ownership and reuse semantics consistent and avoids clashes between C# reference semantics and ILNumerics' buffer management model.ILN0005 — ILNumerics fields should use
localMember<T>()and safe assignmentInstance fields of ILNumerics
Array<T>types are treated as local members: they should be initialized vialocalMember<T>().ILN0005flags non‑staticArray<T>fields that either have no initializer or use something other thanlocalMember<T>(). Valid writes to fields must use either_A.a = ...or_A.Assign(...), which keeps the field buffer stable following expected lifetime conventions.ILN0006 — Use
GetValue()/SetValue()for scalar element accessScalar reads from ILNumerics
Array<T>should useGetValue(...)rather than indexer access combined with an explicit cast (for example:(T) A[i, j]).ILN0006reports cases where an element access is cast to the array's element type, and the code fix rewrites it toA.GetValue(i, j)to make scalar access explicit and consistent.
Troubleshooting
No squiggles but lightbulb available: enable live analysis in the IDE (VS: Tools → Options → Text Editor → C# → Advanced → Enable .NET analyzers, Full solution analysis) and ensure .editorconfig does not suppress diagnostics.
Contributing
Contributions, bug reports and feature requests are welcome. Please open an issue or a pull request on the GitHub repository.
License
ILNumerics.Community.Analyzers is licensed under the terms of the MIT license (http://opensource.org/licenses/MIT, see LICENSE.txt).
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.