forked from ionide/FSharp.Analyzers.SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgrammatic access.fsx
31 lines (25 loc) · 1018 Bytes
/
Programmatic access.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(**
---
category: end-users
categoryindex: 2
index: 3
---
# Programmatically running an analyzer
Using the [SDK](https://www.nuget.org/packages/FSharp.Analyzers.SDK), it is possible to invoke analyzers programmatically.
This can be done via the [Client](../reference/fsharp-analyzers-sdk-client-2.html) type.
The `Client` needs to know what type of analyzer you intend to load: *console* or *editor*.
*)
(*** hide ***)
#r "../../artifacts/bin/FSharp.Analyzers.SDK/release/FSharp.Analyzers.SDK.dll"
#r "../../artifacts/bin/FSharp.Analyzers.Cli/release/FSharp.Compiler.Service.dll"
#r "../../artifacts/bin/FSharp.Analyzers.Cli/release/Microsoft.Extensions.Logging.Abstractions.dll"
(** *)
open FSharp.Analyzers.SDK
let client = Client<CliAnalyzerAttribute, CliContext>()
let countLoaded = client.LoadAnalyzers @"C:\MyAnalyzers"
let ctx = Unchecked.defaultof<CliContext> // Construct your context...
client.RunAnalyzers(ctx)
(**
[Previous]({{fsdocs-previous-page-link}})
[Next]({{fsdocs-next-page-link}})
*)