Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional warn on #1207

Merged
merged 9 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<PackageLicenseExpression Condition=" '$(PackAsTool)' != 'true' ">Apache-2.0</PackageLicenseExpression>
<NoWarn>$(NoWarn);3186,0042</NoWarn><!-- circumvent an error with the fake dependencymanager for paket: https://github.com/dotnet/fsharp/issues/8678 -->
<NoWarn>$(NoWarn);NU1902</NoWarn><!-- NU1902 - package vulnerability detected -->
<WarnOn>$(WarnOn);1182</WarnOn> <!-- Unused variables,https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-options#opt-in-warnings -->
<WarnOn>$(WarnOn);3390</WarnOn><!-- Malformed XML doc comments -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ChangelogFile>$(MSBuildThisFileDirectory)CHANGELOG.md</ChangelogFile>
</PropertyGroup>
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/Program.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Benchmarks

open System
open BenchmarkDotNet
open BenchmarkDotNet.Attributes
Expand All @@ -11,6 +12,6 @@ open System.Security.Cryptography
module EntryPoint =

[<EntryPoint>]
let main argv =
let summary = BenchmarkRunner.Run<SourceText_LineChanges_Benchmarks>();
let main _argv =
let _summary = BenchmarkRunner.Run<SourceText_LineChanges_Benchmarks>()
0
2 changes: 0 additions & 2 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ let init args =
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)
Target.initEnvironment ()

let fsacAssemblies = "FsAutoComplete|FsAutoComplete.Core|LanguageServerProtocol"

let packAsToolProp = "PackAsTool", "true"

Target.create "LspTest" (fun _ ->
Expand Down
25 changes: 13 additions & 12 deletions src/FsAutoComplete.Core/AbstractClassStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let private (|ExplicitCtor|_|) =
| _ -> None

/// checks to see if a type definition inherits an abstract class, and if so collects the members defined at that
let private walkTypeDefn (SynTypeDefn(info, repr, members, implicitCtor, range, trivia)) =
let private walkTypeDefn (SynTypeDefn(_, repr, members, implicitCtor, _, _)) =
option {
let reprMembers =
match repr with
Expand All @@ -47,7 +47,7 @@ let private walkTypeDefn (SynTypeDefn(info, repr, members, implicitCtor, range,
let! inheritType, inheritMemberRange = // this must exist for abstract types
allMembers
|> List.tryPick (function
| SynMemberDefn.ImplicitInherit(inheritType, inheritArgs, alias, range) -> Some(inheritType, range)
| SynMemberDefn.ImplicitInherit(inheritType, _, _, range) -> Some(inheritType, range)
| _ -> None)

let furthestMemberToSkip, otherMembers =
Expand Down Expand Up @@ -82,13 +82,14 @@ let private tryFindAbstractClassExprInParsedInput
{ new SyntaxVisitorBase<_>() with
member _.VisitExpr(path, traverseExpr, defaultTraverse, expr) =
match expr with
| SynExpr.ObjExpr(baseTy, constructorArgs, withKeyword, bindings, members, extraImpls, newExprRange, range) ->
| SynExpr.ObjExpr(
objType = baseTy; withKeyword = withKeyword; bindings = bindings; newExprRange = newExprRange) ->
Some(AbstractClassData.ObjExpr(baseTy, bindings, newExprRange, withKeyword))
| _ -> defaultTraverse expr

override _.VisitModuleDecl(_, defaultTraverse, decl) =
match decl with
| SynModuleDecl.Types(types, m) -> List.tryPick walkTypeDefn types
| SynModuleDecl.Types(types, _) -> List.tryPick walkTypeDefn types
| _ -> defaultTraverse decl }
)

Expand All @@ -104,12 +105,12 @@ let tryFindAbstractClassExprInBufferAtPos
return! tryFindAbstractClassExprInParsedInput pos parseResults.ParseTree
}

let getMemberNameAndRanges (abstractClassData) =
let getMemberNameAndRanges abstractClassData =
match abstractClassData with
| AbstractClassData.ExplicitImpl(members = members) ->
members
|> Seq.choose (function
| (SynMemberDefn.Member(binding, _)) -> Some binding
| SynMemberDefn.Member(binding, _) -> Some binding
| _ -> None)
|> Seq.choose (|MemberNamePlusRangeAndKeywordRange|_|)
|> Seq.toList
Expand All @@ -130,7 +131,7 @@ let inferStartColumn
| AbstractClassData.ExplicitImpl(inheritExpressionRange = inheritRange) ->
// 'interface ISomething with' is often in a new line, we use the indentation of that line
inheritRange.StartColumn
| AbstractClassData.ObjExpr(newExpression = newExpr; withKeyword = withKeyword; bindings = bindings) ->
| AbstractClassData.ObjExpr(newExpression = newExpr; withKeyword = withKeyword; bindings = _) ->
// two cases here to consider:
// * has a with keyword on same line as newExpr
match withKeyword with
Expand All @@ -153,19 +154,19 @@ let writeAbstractClassStub
(codeGenServer: ICodeGenerationService)
(checkResultForFile: ParseAndCheckResults)
(doc: IFSACSourceText)
(lineStr: string)
(_: string)
(abstractClassData: AbstractClassData)
=
asyncOption {
let pos =
Position.mkPos
abstractClassData.AbstractTypeIdentRange.Start.Line
(abstractClassData.AbstractTypeIdentRange.End.Column)
abstractClassData.AbstractTypeIdentRange.End.Column

let! (_lexerSym, usages) = codeGenServer.GetSymbolAndUseAtPositionOfKind(doc.FileName, pos, SymbolKind.Ident)
let! _lexerSym, usages = codeGenServer.GetSymbolAndUseAtPositionOfKind(doc.FileName, pos, SymbolKind.Ident)
let! usage = usages

let! (displayContext, entity) =
let! displayContext, entity =
asyncOption {
// need the enclosing entity because we're always looking at a ctor, which isn't an Entity, but a MemberOrFunctionOrValue
match usage.Symbol with
Expand All @@ -178,7 +179,7 @@ let writeAbstractClassStub
| _ -> return! None
}

let getMemberByLocation (name: string, range: Range, keywordRange: Range) =
let getMemberByLocation (_: string, range: Range, _: Range) =
match doc.GetLine range.Start with
| Some lineText ->
match Lexer.getSymbol range.Start.Line range.Start.Column lineText SymbolLookupKind.ByLongIdent [||] with
Expand Down
8 changes: 4 additions & 4 deletions src/FsAutoComplete.Core/AdaptiveExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type MapDisposableTupleVal<'T1, 'T2, 'Disposable when 'Disposable :> IDisposable

match cache with
| ValueSome(struct (a, b, _)) when Utils.cheapEqual a i -> b
| ValueSome(struct (a, b, c)) ->
| ValueSome(struct (_, _, c)) ->
(c :> IDisposable).Dispose()
let (b, c) = mapping i
cache <- ValueSome(struct (i, b, c))
Expand Down Expand Up @@ -209,7 +209,7 @@ module AMap =
dirty <- HashMap.empty
d)

override x.InputChangedObject(t, o) =
override x.InputChangedObject(_, o) =
#if FABLE_COMPILER
if isNull o.Tag then
let o = unbox<aval<'b>> o
Expand Down Expand Up @@ -316,7 +316,7 @@ module AMap =
=
let mapping =
mapping
>> HashMap.map (fun _ v -> AVal.constant v |> AVal.mapWithAdditionalDependencies (id))
>> HashMap.map (fun _ v -> AVal.constant v |> AVal.mapWithAdditionalDependencies id)

batchRecalcDirty mapping map

Expand Down Expand Up @@ -416,7 +416,7 @@ module Async =
return! ct.Task |> Async.AwaitTask
}

[<AutoOpenAttribute>]
[<AutoOpen>]
module Extensions =

type IcedTasks.CancellableTaskBase.CancellableTaskBuilderBase with
Expand Down
2 changes: 1 addition & 1 deletion src/FsAutoComplete.Core/CodeGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ module CodeGenerationUtils =

let getAbstractNonVirtualMembers (e: FSharpEntity) =
seq {
let genericParams = e.GenericParameters :> seq<_>
let _genericParams = e.GenericParameters :> seq<_>
// todo: generic param instantiations?
yield!
e.MembersFunctionsAndValues
Expand Down
17 changes: 7 additions & 10 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ module Commands =
(tyRes: ParseAndCheckResults)
(pos: Position)
(lines: IFSACSourceText)
(line: LineStr)
=
async {
let doc = docForText lines tyRes
Expand Down Expand Up @@ -363,7 +362,6 @@ module Commands =
(tyRes: ParseAndCheckResults)
(pos: Position)
(lines: ISourceText)
(line: LineStr)
=
async {

Expand Down Expand Up @@ -560,8 +558,8 @@ module Commands =

let getStartingPipe =
function
| y :: xs when y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| x :: y :: xs when x.TokenName.ToUpper() = "WHITESPACE" && y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| y :: _ when y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| x :: y :: _ when x.TokenName.ToUpper() = "WHITESPACE" && y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| _ -> None

let folder (lastExpressionLine, lastExpressionLineWasPipe, acc) (currentIndex, currentTokens) =
Expand Down Expand Up @@ -632,8 +630,8 @@ module Commands =

let getStartingPipe =
function
| y :: xs when y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| x :: y :: xs when x.TokenName.ToUpper() = "WHITESPACE" && y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| y :: _ when y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| x :: y :: _ when x.TokenName.ToUpper() = "WHITESPACE" && y.TokenName.ToUpper() = "INFIX_BAR_OP" -> Some y
| _ -> None

let folder (lastExpressionLine, lastExpressionLineWasPipe, acc) (currentIndex, currentTokens) =
Expand Down Expand Up @@ -714,7 +712,7 @@ module Commands =
// adjust column
let pos =
match pos with
| Pos(1, c) -> pos
| Pos(1, _) -> pos
| Pos(l, 0) ->
let prev = getLine (pos.DecLine())
let indentation = detectIndentation prev
Expand All @@ -724,7 +722,7 @@ module Commands =
Position.mkPos l indentation
else
pos
| Pos(_, c) -> pos
| Pos(_, _) -> pos

{ Namespace = n
Position = pos
Expand Down Expand Up @@ -793,7 +791,6 @@ module Commands =
match scope with
| Some(SymbolDeclarationLocation.Projects(projects (*isLocalForProject=*) , true)) -> return projects
| Some(SymbolDeclarationLocation.Projects(projects (*isLocalForProject=*) , false)) ->
let output = ResizeArray<_>()

let! resolvedProjects =
[ for project in projects do
Expand Down Expand Up @@ -977,7 +974,7 @@ module Commands =
///
/// Also does very basic validation of `newName`:
/// * Must be valid operator name when operator
let adjustRenameSymbolNewName pos lineStr (text: IFSACSourceText) (tyRes: ParseAndCheckResults) (newName: string) =
let adjustRenameSymbolNewName pos lineStr (tyRes: ParseAndCheckResults) (newName: string) =
asyncResult {
let! symbolUse =
tyRes.TryGetSymbolUse pos lineStr
Expand Down
18 changes: 2 additions & 16 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
| None, _
| _, None -> p
| Some fsc, Some fsi ->
let toReplace, otherOpts =
let _toReplace, otherOpts =
p.OtherOptions
|> Array.partition (fun opt ->
opt.EndsWith("FSharp.Core.dll", StringComparison.Ordinal)
Expand Down Expand Up @@ -94,20 +94,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
else
opts

let filterBadRuntimeRefs =
let badRefs =
[ "System.Private"
"System.Runtime.WindowsRuntime"
"System.Runtime.WindowsRuntime.UI.Xaml"
"mscorlib" ]
|> List.map (fun p -> p + ".dll")

let containsBadRef (s: string) = badRefs |> List.exists (fun r -> s.EndsWith(r, StringComparison.Ordinal))

fun (projOptions: FSharpProjectOptions) ->
{ projOptions with
OtherOptions = projOptions.OtherOptions |> Array.where (containsBadRef >> not) }

/// ensures that any user-configured include/load files are added to the typechecking context
let addLoadedFiles (projectOptions: FSharpProjectOptions) =
let files = Array.append fsiAdditionalFiles projectOptions.SourceFiles
Expand Down Expand Up @@ -436,7 +422,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
)
}

member __.GetDeclarations(fileName: string<LocalPath>, source, options, version) =
member __.GetDeclarations(fileName: string<LocalPath>, source, options, _) =
async {
checkerLogger.info (
Log.setMessage "GetDeclarations - {file}"
Expand Down
18 changes: 15 additions & 3 deletions src/FsAutoComplete.Core/Debug.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@ module Debug =
return r
}

let toggleVerboseLogging (verbose: bool) = () // todo: set logging latch
let toggleVerboseLogging (_verbose: bool) = () // todo: set logging latch

let waitForDebugger () =
while not (Diagnostics.Debugger.IsAttached) do
System.Threading.Thread.Sleep(100)

let logger = LogProvider.getLoggerByName "Debugging"

let waitForDebuggerAttached (programName) =
let waitForDebuggerAttached
#if DEBUG
programName
#else
_
#endif
=
#if DEBUG
if not (System.Diagnostics.Debugger.IsAttached) then
logger.info (
Expand All @@ -73,7 +79,13 @@ module Debug =
#else
()
#endif
let waitForDebuggerAttachedAndBreak (programName) =
let waitForDebuggerAttachedAndBreak
#if DEBUG
programName
#else
_
#endif
=
#if DEBUG
waitForDebuggerAttached programName
System.Diagnostics.Debugger.Break()
Expand Down
5 changes: 2 additions & 3 deletions src/FsAutoComplete.Core/DocumentationFormatter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ module DocumentationFormatter =

sprintf "active pattern %s: %s" apc.Name findVal

let getAttributeSignature displayContext (attr: FSharpAttribute) =
let getAttributeSignature (attr: FSharpAttribute) =
let name =
formatShowDocumentationLink
attr.AttributeType.DisplayName
Expand Down Expand Up @@ -717,8 +717,7 @@ module DocumentationFormatter =
|> Seq.map (fun inf -> fst (format displayContext inf))
|> Seq.toArray

let attrs =
fse.Attributes |> Seq.map (getAttributeSignature displayContext) |> Seq.toArray
let attrs = fse.Attributes |> Seq.map getAttributeSignature |> Seq.toArray

let types =
fse.NestedEntities
Expand Down
7 changes: 5 additions & 2 deletions src/FsAutoComplete.Core/DotnetNewTemplate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ module DotnetNewTemplate =
let templates =
templateDetails ()
|> List.map (fun t -> t, extractDetailedString t)
|> List.filter (fun (t, strings) -> strings |> List.exists (nameMatch userInput))
|> List.map (fun (t, strings) -> t)
|> List.choose (fun (t, strings) ->
if strings |> List.exists (nameMatch userInput) then
Some t
else
None)

match templates with
| [] -> failwithf "No template exists with name : %s" userInput
Expand Down
6 changes: 3 additions & 3 deletions src/FsAutoComplete.Core/FCSPatches.fs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ module SyntaxTreeOps =
(match copyInfo with
| Some(e, _) -> walkExpr e
| None -> false)
|| walkExprs (recordFields |> List.map (fun (ident, range, expr) -> expr))
|| walkExprs (recordFields |> List.map (fun (_ident, _range, expr) -> expr))

| SynExpr.Record(copyInfo = copyInfo; recordFields = recordFields) ->
(match copyInfo with
Expand Down Expand Up @@ -542,11 +542,11 @@ module SyntaxTreeOps =
| SynInterpolatedStringPart.String _ -> None
| SynInterpolatedStringPart.FillExpr(x, _) -> Some x)
)
| SynExpr.IndexRange(expr1, opm, expr2, range1, range2, range3) ->
| SynExpr.IndexRange(expr1 = expr1; expr2 = expr2) ->
Option.map walkExpr expr1
|> Option.orElseWith (fun _ -> Option.map walkExpr expr2)
|> Option.defaultValue false
| SynExpr.IndexFromEnd(expr, range) -> walkExpr expr
| SynExpr.IndexFromEnd(expr, _) -> walkExpr expr
| SynExpr.DebugPoint(innerExpr = expr) -> walkExpr expr
| SynExpr.Dynamic(funcExpr = funcExpr; argExpr = argExpr) -> walkExpr funcExpr || walkExpr argExpr

Expand Down
2 changes: 1 addition & 1 deletion src/FsAutoComplete.Core/Fsdn.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ let query (queryStr: string) =

let info2 = v.api.name
//return a list of strings
let infoNamespace = info2.``namespace``
let _infoNamespace = info2.``namespace``
let infoClass = info2.class_name
let infoMethod = info2.id

Expand Down
Loading
Loading