Skip to content
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
1 change: 0 additions & 1 deletion .fantomasignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ src/Compiler/**/*.fs
src/fsc/**/*.fs
src/fscAnyCpu/**/*.fs
src/FSharp.Build/**/*.fs
src/FSharp.Compiler.Interactive.Settings/**/*.fs
src/FSharp.Compiler.Server.Shared/**/*.fs
src/FSharp.DependencyManager.Nuget/**/*.fs
src/fsi/**/*.fs
Expand Down
6 changes: 2 additions & 4 deletions src/Compiler/AbstractIL/ilsupp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -878,16 +878,13 @@ let pdbInitialize (binaryName: string) (pdbName: string) =
{ symWriter = writer }


[<assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001: AvoidCallingProblematicMethods", Scope="member", Target="FSharp.Compiler.AbstractIL.Support.#pdbClose(FSharp.Compiler.AbstractIL.Support+PdbWriter)", MessageId="System.GC.Collect")>]
do()

let pdbCloseDocument(documentWriter: PdbDocumentWriter) =
Marshal.ReleaseComObject (documentWriter.symDocWriter)
|> ignore

[<System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001: AvoidCallingProblematicMethods", MessageId="System.GC.Collect")>]
let pdbClose (writer: PdbWriter) dllFilename pdbFilename =
writer.symWriter.Close()

// CorSymWriter objects (ISymUnmanagedWriter) lock the files they're operating
// on (both the pdb and the binary). The locks are released only when their ref
// count reaches zero, but since we're dealing with RCWs, there's no telling when
Expand All @@ -897,6 +894,7 @@ let pdbClose (writer: PdbWriter) dllFilename pdbFilename =
// interface, which the SymWriter class, unfortunately, does not.
// Right now, take the same approach as mdbg, and manually forcing a collection.
let rc = Marshal.ReleaseComObject(writer.symWriter)

for i = 0 to (rc - 1) do
Marshal.ReleaseComObject(writer.symWriter) |> ignore

Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,6 @@ module internal MagicAssemblyResolution =
// It is an explicit user trust decision to load an assembly with #r. Scripts are not run automatically (for example, by double-clicking in explorer).
// We considered setting loadFromRemoteSources in fsi.exe.config but this would transitively confer unsafe loading to the code in the referenced
// assemblies. Better to let those assemblies decide for themselves which is safer.
[<CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId="System.Reflection.Assembly.UnsafeLoadFrom")>]
let private assemblyLoadFrom (path:string) = Assembly.UnsafeLoadFrom(path)

let ResolveAssembly (ctok, m, tcConfigB, tcImports: TcImports, fsiDynamicCompiler: FsiDynamicCompiler, fsiConsoleOutput: FsiConsoleOutput, fullAssemName: string) =
Expand Down Expand Up @@ -3591,7 +3590,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i
///
/// A background thread is started by this thread to read from the inReader and/or console reader.

[<CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2004:RemoveCallsToGCKeepAlive")>]
member x.Run() =
progress <- condition "FSHARP_INTERACTIVE_PROGRESS"

Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Service/ServiceLexing.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open System
open System.Threading
open FSharp.Compiler
open FSharp.Compiler.Text

#nowarn "57"

/// Represents encoded information for the end-of-line continuation of lexing
Expand Down
1 change: 0 additions & 1 deletion src/FSharp.Build/Fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ open Internal.Utilities
//The goal is to have the most common/important flags available via the Fsc class, and the
//rest can be "backdoored" through the .OtherFlags property.

[<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")>]
type public Fsc () as this =

inherit ToolTask ()
Expand Down
1 change: 0 additions & 1 deletion src/FSharp.Build/Fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ open Internal.Utilities
//The goal is to have the most common/important flags available via the Fsi class, and the
//rest can be "backdoored" through the .OtherFlags property.

[<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")>]
type public Fsi () as this =

inherit ToolTask ()
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Compiler.Interactive.Settings/fsiattrs.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

module FSharp.Compiler.Interactive.Attributes
[<assembly: AutoOpen("FSharp.Compiler.Interactive.Settings")>]
do()

[<assembly: AutoOpen("FSharp.Compiler.Interactive.Settings")>]
do ()
240 changes: 147 additions & 93 deletions src/FSharp.Compiler.Interactive.Settings/fsiaux.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,90 @@ open System.Diagnostics
open System.Threading

[<assembly: System.Runtime.InteropServices.ComVisible(false)>]
[<assembly: System.CLSCompliant(true)>]
do()
[<assembly: System.CLSCompliant(true)>]
do ()

type IEventLoop =
abstract Run : unit -> bool
abstract Invoke : (unit -> 'T) -> 'T
abstract ScheduleRestart : unit -> unit
abstract Run: unit -> bool
abstract Invoke: (unit -> 'T) -> 'T
abstract ScheduleRestart: unit -> unit

// An implementation of IEventLoop suitable for the command-line console
[<AutoSerializable(false)>]
type internal SimpleEventLoop() =
type internal SimpleEventLoop() =
let runSignal = new AutoResetEvent(false)
let exitSignal = new AutoResetEvent(false)
let doneSignal = new AutoResetEvent(false)
let mutable queue = ([] : (unit -> obj) list)
let mutable result = (None : obj option)
let setSignal(signal : AutoResetEvent) = while not (signal.Set()) do Thread.Sleep(1); done
let waitSignal signal = WaitHandle.WaitAll([| (signal :> WaitHandle) |]) |> ignore
let waitSignal2 signal1 signal2 =
let mutable queue = ([]: (unit -> obj) list)
let mutable result = (None: obj option)

let setSignal (signal: AutoResetEvent) =
while not (signal.Set()) do
Thread.Sleep(1)

let waitSignal signal =
WaitHandle.WaitAll([| (signal :> WaitHandle) |]) |> ignore

let waitSignal2 signal1 signal2 =
WaitHandle.WaitAny([| (signal1 :> WaitHandle); (signal2 :> WaitHandle) |])

let mutable running = false
let mutable restart = false
interface IEventLoop with
member x.Run() =
running <- true
let rec run() =
match waitSignal2 runSignal exitSignal with
| 0 ->
queue |> List.iter (fun f -> result <- try Some(f()) with _ -> None)
setSignal doneSignal
run()
| 1 ->
running <- false
restart
| _ -> run()
run()
member x.Invoke(f : unit -> 'T) : 'T =
queue <- [f >> box]
setSignal runSignal
waitSignal doneSignal
result |> Option.get |> unbox
member x.ScheduleRestart() =
// nb. very minor race condition here on running here, but totally
// unproblematic as ScheduleRestart and Exit are almost never called.
if running then
restart <- true
setSignal exitSignal
interface System.IDisposable with
member x.Dispose() =
runSignal.Dispose()
exitSignal.Dispose()
doneSignal.Dispose()


interface IEventLoop with
member x.Run() =
running <- true

let rec run () =
match waitSignal2 runSignal exitSignal with
| 0 ->
queue
|> List.iter (fun f ->
result <-
try
Some(f ())
with
| _ -> None)

setSignal doneSignal
run ()
| 1 ->
running <- false
restart
| _ -> run ()

run ()

member x.Invoke(f: unit -> 'T) : 'T =
queue <- [ f >> box ]
setSignal runSignal
waitSignal doneSignal
result |> Option.get |> unbox

member x.ScheduleRestart() =
// nb. very minor race condition here on running here, but totally
// unproblematic as ScheduleRestart and Exit are almost never called.
if running then
restart <- true
setSignal exitSignal

interface System.IDisposable with
member x.Dispose() =
runSignal.Dispose()
exitSignal.Dispose()
doneSignal.Dispose()

[<Sealed>]
type InteractiveSession() =
type InteractiveSession() =
let mutable evLoop = (new SimpleEventLoop() :> IEventLoop)
let mutable showIDictionary = true
let mutable showDeclarationValues = true
let mutable args = System.Environment.GetCommandLineArgs()
let mutable args = System.Environment.GetCommandLineArgs()
let mutable fpfmt = "g10"
let mutable fp = (System.Globalization.CultureInfo.InvariantCulture :> System.IFormatProvider)

let mutable fp =
(System.Globalization.CultureInfo.InvariantCulture :> System.IFormatProvider)

let mutable printWidth = 78
let mutable printDepth = 100
let mutable printLength = 100
Expand All @@ -81,59 +102,92 @@ type InteractiveSession() =
let mutable showProperties = true
let mutable addedPrinters = []

member self.FloatingPointFormat with get() = fpfmt and set v = fpfmt <- v
member self.FormatProvider with get() = fp and set v = fp <- v
member self.PrintWidth with get() = printWidth and set v = printWidth <- v
member self.PrintDepth with get() = printDepth and set v = printDepth <- v
member self.PrintLength with get() = printLength and set v = printLength <- v
member self.PrintSize with get() = printSize and set v = printSize <- v
member self.ShowDeclarationValues with get() = showDeclarationValues and set v = showDeclarationValues <- v
member self.ShowProperties with get() = showProperties and set v = showProperties <- v
member self.ShowIEnumerable with get() = showIEnumerable and set v = showIEnumerable <- v
member self.ShowIDictionary with get() = showIDictionary and set v = showIDictionary <- v
member self.AddedPrinters with get() = addedPrinters and set v = addedPrinters <- v

[<CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")>]
member self.CommandLineArgs
with get() = args
and set v = args <- v

member self.AddPrinter(printer : 'T -> string) =
addedPrinters <- Choice1Of2 (typeof<'T>, (fun (x:obj) -> printer (unbox x))) :: addedPrinters

member self.EventLoop
with get () = evLoop
and set (x:IEventLoop) = evLoop.ScheduleRestart(); evLoop <- x

member self.AddPrintTransformer(printer : 'T -> obj) =
addedPrinters <- Choice2Of2 (typeof<'T>, (fun (x:obj) -> printer (unbox x))) :: addedPrinters

member internal self.SetEventLoop (run: (unit -> bool), invoke: ((unit -> obj) -> obj), restart: (unit -> unit)) =
evLoop.ScheduleRestart()
evLoop <- { new IEventLoop with
member _.Run() = run()
member _.Invoke(f) = invoke((fun () -> f() |> box)) |> unbox
member _.ScheduleRestart() = restart() }

[<assembly: CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly", Scope="member", Target="FSharp.Compiler.Interactive.InteractiveSession.#ThreadException")>]
do()


module Settings =
member _.FloatingPointFormat
with get () = fpfmt
and set v = fpfmt <- v

member _.FormatProvider
with get () = fp
and set v = fp <- v

member _.PrintWidth
with get () = printWidth
and set v = printWidth <- v

member _.PrintDepth
with get () = printDepth
and set v = printDepth <- v

member _.PrintLength
with get () = printLength
and set v = printLength <- v

member _.PrintSize
with get () = printSize
and set v = printSize <- v

member _.ShowDeclarationValues
with get () = showDeclarationValues
and set v = showDeclarationValues <- v

member _.ShowProperties
with get () = showProperties
and set v = showProperties <- v

member _.ShowIEnumerable
with get () = showIEnumerable
and set v = showIEnumerable <- v

member _.ShowIDictionary
with get () = showIDictionary
and set v = showIDictionary <- v

member _.AddedPrinters
with get () = addedPrinters
and set v = addedPrinters <- v

member _.CommandLineArgs
with get () = args
and set v = args <- v

member _.AddPrinter(printer: 'T -> string) =
addedPrinters <- Choice1Of2(typeof<'T>, (fun (x: obj) -> printer (unbox x))) :: addedPrinters

member _.EventLoop
with get () = evLoop
and set (x: IEventLoop) =
evLoop.ScheduleRestart()
evLoop <- x

member _.AddPrintTransformer(printer: 'T -> obj) =
addedPrinters <- Choice2Of2(typeof<'T>, (fun (x: obj) -> printer (unbox x))) :: addedPrinters

member internal self.SetEventLoop(run: (unit -> bool), invoke: ((unit -> obj) -> obj), restart: (unit -> unit)) =
evLoop.ScheduleRestart()

evLoop <-
{ new IEventLoop with
member _.Run() = run ()

member _.Invoke(f) =
invoke ((fun () -> f () |> box)) |> unbox

member _.ScheduleRestart() = restart ()
}

module Settings =
let fsi = new InteractiveSession()

[<assembly: AutoOpen("FSharp.Compiler.Interactive.Settings")>]
do()
do ()

// For legacy compatibility with old naming
namespace Microsoft.FSharp.Compiler.Interactive

type IEventLoop = FSharp.Compiler.Interactive.IEventLoop

type InteractiveSession = FSharp.Compiler.Interactive.InteractiveSession

module Settings =
type IEventLoop = FSharp.Compiler.Interactive.IEventLoop

let fsi = FSharp.Compiler.Interactive.Settings.fsi
type InteractiveSession = FSharp.Compiler.Interactive.InteractiveSession

module Settings =

let fsi = FSharp.Compiler.Interactive.Settings.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type internal FSharpInteractiveServer() =
abstract Interrupt : unit -> unit
default x.Interrupt() = ()

[<CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")>]
static member StartServer(channelName:string,server:FSharpInteractiveServer) =
let chan = new Ipc.IpcChannel(channelName)
LifetimeServices.LeaseTime <- TimeSpan(7,0,0,0); // days,hours,mins,secs
Expand Down
1 change: 0 additions & 1 deletion src/FSharp.Core/array.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ namespace Microsoft.FSharp.Collections
[<CompiledName("Empty")>]
let empty<'T> : 'T [] = [| |]

[<CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704: IdentifiersShouldBeSpelledCorrectly")>]
[<CompiledName("CopyTo")>]
let inline blit (source: 'T[]) (sourceIndex: int) (target: 'T[]) (targetIndex: int) (count: int) =
Array.Copy(source, sourceIndex, target, targetIndex, count)
Expand Down
3 changes: 0 additions & 3 deletions src/FSharp.Core/local.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ module internal List =

let inline arrayZeroCreate (n:int) = (# "newarr !0" type ('T) n : 'T array #)

[<SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")>]
let nonempty x = match x with [] -> false | _ -> true

// optimized mutation-based implementation. This code is only valid in fslib, where mutation of private
// tail cons cells is permitted in carefully written library code.
let inline setFreshConsTail cons t = cons.( :: ).1 <- t
Expand Down
1 change: 0 additions & 1 deletion src/FSharp.Core/map.fs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ module MapTree =
[<System.Diagnostics.DebuggerTypeProxy(typedefof<MapDebugView<_, _>>)>]
[<System.Diagnostics.DebuggerDisplay("Count = {Count}")>]
[<Sealed>]
[<CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710: IdentifiersShouldHaveCorrectSuffix")>]
[<CompiledName("FSharpMap`2")>]
type Map<[<EqualityConditionalOn>]'Key, [<EqualityConditionalOn; ComparisonConditionalOn>]'Value when 'Key : comparison >(comparer: IComparer<'Key>, tree: MapTree<'Key, 'Value>) =

Expand Down
Loading