未验证 提交 0006b73b 编写于 作者: D Don Syme 提交者: GitHub

format one implementation file and remove SuppressMessage (#13153)

* format one imlpementation file and remove SuppressMessage

* format one imlpementation file and remove SuppressMessage

* apply formatting
Co-authored-by: NKevin Ransom (msft) <codecutter@hotmail.com>
上级 5c9d7917
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -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) =
......@@ -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"
......
......@@ -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
......
......@@ -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 ()
......
......@@ -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 ()
......
// 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 ()
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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>) =
......
此差异已折叠。
......@@ -78,7 +78,6 @@ open Helpers
[<Sealed>]
[<CompiledName("FSharpVar")>]
[<System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification="Equals override does not equate further objects, so default GetHashCode is still valid")>]
type Var(name: string, typ: Type, ?isMutable: bool) =
inherit obj()
......
......@@ -1073,7 +1073,6 @@ module Seq =
let cached = cache source2
source1 |> collect (fun x -> cached |> map (fun y -> x, y))
[<CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1709:IdentifiersShouldBeCasedCorrectly"); CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1707:IdentifiersShouldNotContainUnderscores"); CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1704:IdentifiersShouldBeSpelledCorrectly")>]
[<CompiledName("ReadOnly")>]
let readonly (source:seq<_>) =
checkNonNull "source" source
......
......@@ -558,7 +558,6 @@ module internal SetTree =
[<CompiledName("FSharpSet`1")>]
[<DebuggerTypeProxy(typedefof<SetDebugView<_>>)>]
[<DebuggerDisplay("Count = {Count}")>]
[<CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")>]
type Set<[<EqualityConditionalOn>]'T when 'T: comparison >(comparer:IComparer<'T>, tree: SetTree<'T>) =
[<System.NonSerialized>]
......@@ -663,14 +662,12 @@ type Set<[<EqualityConditionalOn>]'T when 'T: comparison >(comparer:IComparer<'T
member s.ForAll f =
SetTree.forall f s.Tree
[<System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates")>]
static member (-) (set1: Set<'T>, set2: Set<'T>) =
if SetTree.isEmpty set1.Tree then set1 (* 0 - B = 0 *)
else
if SetTree.isEmpty set2.Tree then set1 (* A - 0 = A *)
else Set(set1.Comparer, SetTree.diff set1.Comparer set1.Tree set2.Tree)
[<System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates")>]
static member (+) (set1: Set<'T>, set2: Set<'T>) =
#if TRACE_SETS_AND_MAPS
SetTree.report()
......
......@@ -265,7 +265,6 @@ type internal FSharpColorizer_DEPRECATED
| None -> () }
tokens() |> Array.ofSeq
[<CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId="length-1")>] // exceeds EndIndex
member private c.GetColorInfo(line,lineText,length,lastColorState) =
let refState = ref (ColorStateLookup_DEPRECATED.LexStateOfColorState lastColorState)
scanner.SetLineText lineText
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册