Skip to content

Commit

Permalink
use optional parameter instead of overloaded member
Browse files Browse the repository at this point in the history
  • Loading branch information
dawedawe committed Jan 3, 2024
1 parent 7acb6d2 commit e423b4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
7 changes: 3 additions & 4 deletions src/FSharp.Analyzers.Cli/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,14 @@ let main argv =
let includeAnalyzers = results.GetResult(<@ Include_Analyzer @>, [])

match excludeAnalyzers, includeAnalyzers with
| [], [] -> None
| e, [] -> Some(Exclude(Set.ofList e))
| [], i -> Some(Include(Set.ofList i))
| e, [] -> Exclude(Set.ofList e)
| [], i -> Include(Set.ofList i)
| i, _e ->
logger.LogWarning(
"--exclude-analyzers and --include-analyzers are mutually exclusive, ignoring --exclude-analyzers"
)

Some(Include(Set.ofList i))
Include(Set.ofList i)

AssemblyLoadContext.Default.add_Resolving (fun _ctx assemblyName ->
if assemblyName.Name <> "FSharp.Core" then
Expand Down
4 changes: 1 addition & 3 deletions src/FSharp.Analyzers.SDK/FSharp.Analyzers.SDK.Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ type Client<'TAttribute, 'TContext when 'TAttribute :> AnalyzerAttribute and 'TC

new() = Client(Abstractions.NullLogger.Instance)

member x.LoadAnalyzers(dir: string) : int * int = x.LoadAnalyzers(dir, None)

member x.LoadAnalyzers(dir: string, excludeInclude: ExcludeInclude option) : int * int =
member x.LoadAnalyzers(dir: string, ?excludeInclude: ExcludeInclude) : int * int =
if Directory.Exists dir then
let analyzerAssemblies =
let regex = Regex(@".*test.*\.dll$")
Expand Down
10 changes: 2 additions & 8 deletions src/FSharp.Analyzers.SDK/FSharp.Analyzers.SDK.Client.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@ type Client<'TAttribute, 'TContext when 'TAttribute :> AnalyzerAttribute and 'TC
/// <summary>
/// Loads into private state any analyzers defined in any assembly
/// matching `*Analyzer*.dll` in given directory (and any subdirectories)
/// Analyzers are filtered according to the ExcludeInclude set, if provided.
/// </summary>
/// <returns>number of found dlls matching `*Analyzer*.dll` and number of registered analyzers</returns>
member LoadAnalyzers: dir: string -> int * int
/// <summary>
/// Loads into private state any analyzers defined in any assembly
/// matching `*Analyzer*.dll` in given directory (and any subdirectories)
/// Analyzers are filtered according to the given ExcludeInclude set.
/// </summary>
/// <returns>number of found dlls matching `*Analyzer*.dll` and number of registered analyzers</returns>
member LoadAnalyzers: dir: string * excludeInclude: ExcludeInclude option -> int * int
member LoadAnalyzers: dir: string * ?excludeInclude: ExcludeInclude -> int * int
/// <summary>Runs all registered analyzers for given context (file).</summary>
/// <returns>list of messages. Ignores errors from the analyzers</returns>
member RunAnalyzers: ctx: 'TContext -> Async<AnalyzerMessage list>
Expand Down

0 comments on commit e423b4b

Please sign in to comment.