From 2b16de00addad48e0db3d9a2fa4bdd4e7d1b6cfb Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Thu, 15 Aug 2024 15:00:17 +0100 Subject: [PATCH] net9pv7 passes static analysis --- .github/workflows/main.yml | 4 +- AltCover.Avalonia/MainWindow.fs | 17 ++- AltCover.Avalonia/Persistence.fs | 1 + AltCover.DotNet/DotNet.fs | 15 +-- AltCover.Engine/AltCover.fs | 168 +++++++++++++--------------- AltCover.Engine/CecilEx.fs | 10 +- AltCover.Engine/Instrument.fs | 39 ++----- AltCover.Engine/Main.fs | 4 +- AltCover.Engine/NativeJson.fs | 3 +- AltCover.Engine/PostProcess.fs | 36 ++++++ AltCover.Engine/Runner.fs | 12 ++ AltCover.Engine/Visitor.fs | 57 +++++----- AltCover.Fake/Fake.fs | 5 + AltCover.PowerShell/Accelerator.fs | 14 ++- AltCover.PowerShell/XhtmlReports.fs | 10 +- AltCover.Toolkit/OpenCover.fs | 2 +- AltCover.Visualizer/Persistence.fs | 5 + AltCover.Visualizer/Visualizer.fs | 11 ++ Build/targets.fs | 88 --------------- bootstrap.ps1 | 3 + global.json | 2 +- 21 files changed, 246 insertions(+), 260 deletions(-) create mode 100644 bootstrap.ps1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 711aae060..a6eb5fb44 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.100-preview.6.24328.19' + dotnet-version: '9.0.100-preview.7.24407.12' - name: Tools run: dotnet tool restore - name: Setup @@ -63,7 +63,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.100-preview.6.24328.19' + dotnet-version: '9.0.100-preview.7.24407.12' - name: Tools run: dotnet tool restore - name: Setup diff --git a/AltCover.Avalonia/MainWindow.fs b/AltCover.Avalonia/MainWindow.fs index 439b52791..78d4cc2f6 100644 --- a/AltCover.Avalonia/MainWindow.fs +++ b/AltCover.Avalonia/MainWindow.fs @@ -841,7 +841,11 @@ type MainWindow() as this = "exit" ] |> Seq.iter (fun n -> let cap = - n.First().ToString().ToUpper() + n.Substring(1) + n + .First() + .ToString() + .ToUpper(CultureInfo.InvariantCulture) + + n.Substring(1) let raw = Resource.GetResourceString(n + "Button.Label") @@ -1091,8 +1095,9 @@ type MainWindow() as this = t.Text <- String.Empty // clear format stashes -- TODO #if !AVALONIA11 - t.FormattedText.Spans <- [] - t.Tag <- t.FormattedText.Spans + let ft = t.FormattedText + ft.Spans <- [] + t.Tag <- ft.Spans #endif ) @@ -1159,4 +1164,10 @@ type MainWindow() as this = Target = "AltCover.MainWindow", Justification = "God Object, alas")>] #endif +[,AltCover.GuiCommon/CodeTag)", + Justification = "Wrong paradigm")>] () \ No newline at end of file diff --git a/AltCover.Avalonia/Persistence.fs b/AltCover.Avalonia/Persistence.fs index b4eb5401e..041819575 100644 --- a/AltCover.Avalonia/Persistence.fs +++ b/AltCover.Avalonia/Persistence.fs @@ -1,6 +1,7 @@ namespace AltCover open System +open System.Diagnostics.CodeAnalysis open Avalonia open Avalonia.Controls diff --git a/AltCover.DotNet/DotNet.fs b/AltCover.DotNet/DotNet.fs index f15be739f..c13952208 100644 --- a/AltCover.DotNet/DotNet.fs +++ b/AltCover.DotNet/DotNet.fs @@ -226,14 +226,15 @@ module DotNet = [] #else -[.$DotNet.#.cctor()", - Justification = "Compiler generated")>] +//[.$DotNet.#.cctor()", +// Justification = "Compiler generated")>] + #endif () \ No newline at end of file diff --git a/AltCover.Engine/AltCover.fs b/AltCover.Engine/AltCover.fs index c2137c007..1a2395eb0 100644 --- a/AltCover.Engine/AltCover.fs +++ b/AltCover.Engine/AltCover.fs @@ -46,8 +46,24 @@ module AltCover = Environment.NewLine, Seq.concat [ [| cl |] |> Array.toSeq; self.Errors ] ) + + let validateArraySimple a f = a |> Seq.iter (f >> ignore) + + let validateArray a f key = validateArraySimple a (f key) + + let validateOptional f key x = + if x |> String.IsNullOrWhiteSpace |> not then + f key x |> ignore + #endif + let toSeq (s: 'a seq) = + match s with + | null -> Seq.empty<'a> + | _ -> s + + let toList (s: 'a seq) = s |> toSeq |> Seq.toList + [ Seq.empty - | _ -> s - member self.RecorderDirectory = match self with | Primitive p -> p.RecorderDirectory @@ -112,8 +123,8 @@ module AltCover = member self.CommandLine = match self with - | Primitive p -> p.CommandLine |> CollectOptions.ToSeq - | Abstract a -> a.CommandLine |> CollectOptions.ToSeq + | Primitive p -> p.CommandLine |> toSeq + | Abstract a -> a.CommandLine |> toSeq | TypeSafe t -> t.CommandLine.AsStrings() member self.ExposeReturnCode = @@ -205,41 +216,34 @@ module AltCover = | TypeSafe of TypeSafe.PrepareOptions | Abstract of Abstract.IPrepareOptions - static member private ToSeq(s: 'a seq) = - match s with - | null -> Seq.empty<'a> - | _ -> s - - static member private ToList(s: 'a seq) = s |> PrepareOptions.ToSeq |> Seq.toList - member self.InputDirectories = match self with - | Primitive p -> p.InputDirectories |> PrepareOptions.ToList - | Abstract a -> a.InputDirectories |> PrepareOptions.ToList + | Primitive p -> p.InputDirectories |> toList + | Abstract a -> a.InputDirectories |> toList | TypeSafe t -> t.InputDirectories.AsStrings() member self.OutputDirectories = match self with - | Primitive p -> p.OutputDirectories |> PrepareOptions.ToList - | Abstract a -> a.OutputDirectories |> PrepareOptions.ToList + | Primitive p -> p.OutputDirectories |> toList + | Abstract a -> a.OutputDirectories |> toList | TypeSafe t -> t.OutputDirectories.AsStrings() member self.SymbolDirectories = match self with - | Primitive p -> p.SymbolDirectories |> PrepareOptions.ToList - | Abstract a -> a.SymbolDirectories |> PrepareOptions.ToList + | Primitive p -> p.SymbolDirectories |> toList + | Abstract a -> a.SymbolDirectories |> toList | TypeSafe t -> t.SymbolDirectories.AsStrings() member self.Dependencies = match self with - | Primitive p -> p.Dependencies |> PrepareOptions.ToList - | Abstract a -> a.Dependencies |> PrepareOptions.ToList + | Primitive p -> p.Dependencies |> toList + | Abstract a -> a.Dependencies |> toList | TypeSafe t -> t.Dependencies.AsStrings() member self.Keys = match self with - | Primitive p -> p.Keys |> PrepareOptions.ToList - | Abstract a -> a.Keys |> PrepareOptions.ToList + | Primitive p -> p.Keys |> toList + | Abstract a -> a.Keys |> toList | TypeSafe t -> t.Keys.AsStrings() member self.StrongNameKey = @@ -256,68 +260,68 @@ module AltCover = member self.FileFilter = match self with - | Primitive p -> p.FileFilter |> PrepareOptions.ToList - | Abstract a -> a.FileFilter |> PrepareOptions.ToList + | Primitive p -> p.FileFilter |> toList + | Abstract a -> a.FileFilter |> toList | TypeSafe t -> t.FileFilter.AsStrings() member self.AssemblyFilter = match self with - | Primitive p -> p.AssemblyFilter |> PrepareOptions.ToList - | Abstract a -> a.AssemblyFilter |> PrepareOptions.ToList + | Primitive p -> p.AssemblyFilter |> toList + | Abstract a -> a.AssemblyFilter |> toList | TypeSafe t -> t.AssemblyFilter.AsStrings() member self.AssemblyExcludeFilter = match self with - | Primitive p -> p.AssemblyExcludeFilter |> PrepareOptions.ToList - | Abstract a -> a.AssemblyExcludeFilter |> PrepareOptions.ToList + | Primitive p -> p.AssemblyExcludeFilter |> toList + | Abstract a -> a.AssemblyExcludeFilter |> toList | TypeSafe t -> t.AssemblyExcludeFilter.AsStrings() member self.TypeFilter = match self with - | Primitive p -> p.TypeFilter |> PrepareOptions.ToList - | Abstract a -> a.TypeFilter |> PrepareOptions.ToList + | Primitive p -> p.TypeFilter |> toList + | Abstract a -> a.TypeFilter |> toList | TypeSafe t -> t.TypeFilter.AsStrings() member self.MethodFilter = match self with - | Primitive p -> p.MethodFilter |> PrepareOptions.ToList - | Abstract a -> a.MethodFilter |> PrepareOptions.ToList + | Primitive p -> p.MethodFilter |> toList + | Abstract a -> a.MethodFilter |> toList | TypeSafe t -> t.MethodFilter.AsStrings() member self.AttributeFilter = match self with - | Primitive p -> p.AttributeFilter |> PrepareOptions.ToList - | Abstract a -> a.AttributeFilter |> PrepareOptions.ToList + | Primitive p -> p.AttributeFilter |> toList + | Abstract a -> a.AttributeFilter |> toList | TypeSafe t -> t.AttributeFilter.AsStrings() member self.PathFilter = match self with - | Primitive p -> p.PathFilter |> PrepareOptions.ToList - | Abstract a -> a.PathFilter |> PrepareOptions.ToList + | Primitive p -> p.PathFilter |> toList + | Abstract a -> a.PathFilter |> toList | TypeSafe t -> t.PathFilter.AsStrings() member self.AttributeTopLevel = match self with - | Primitive p -> p.AttributeTopLevel |> PrepareOptions.ToList - | Abstract a -> a.AttributeTopLevel |> PrepareOptions.ToList + | Primitive p -> p.AttributeTopLevel |> toList + | Abstract a -> a.AttributeTopLevel |> toList | TypeSafe t -> t.AttributeTopLevel.AsStrings() member self.TypeTopLevel = match self with - | Primitive p -> p.TypeTopLevel |> PrepareOptions.ToList - | Abstract a -> a.TypeTopLevel |> PrepareOptions.ToList + | Primitive p -> p.TypeTopLevel |> toList + | Abstract a -> a.TypeTopLevel |> toList | TypeSafe t -> t.TypeTopLevel.AsStrings() member self.MethodTopLevel = match self with - | Primitive p -> p.MethodTopLevel |> PrepareOptions.ToList - | Abstract a -> a.MethodTopLevel |> PrepareOptions.ToList + | Primitive p -> p.MethodTopLevel |> toList + | Abstract a -> a.MethodTopLevel |> toList | TypeSafe t -> t.MethodTopLevel.AsStrings() member self.CallContext = match self with - | Primitive p -> p.CallContext |> PrepareOptions.ToList - | Abstract a -> a.CallContext |> PrepareOptions.ToList + | Primitive p -> p.CallContext |> toList + | Abstract a -> a.CallContext |> toList | TypeSafe t -> t.CallContext.AsStrings() member self.ReportFormat = @@ -376,8 +380,8 @@ module AltCover = member self.CommandLine = match self with - | Primitive p -> p.CommandLine |> PrepareOptions.ToSeq - | Abstract a -> a.CommandLine |> PrepareOptions.ToSeq + | Primitive p -> p.CommandLine |> toSeq + | Abstract a -> a.CommandLine |> toSeq | TypeSafe t -> t.CommandLine.AsStrings() member self.ExposeReturnCode = @@ -448,55 +452,54 @@ module AltCover = interface Abstract.IPrepareOptions with member self.InputDirectories = - self.InputDirectories |> PrepareOptions.ToSeq + self.InputDirectories |> toSeq member self.OutputDirectories = - self.OutputDirectories |> PrepareOptions.ToSeq + self.OutputDirectories |> toSeq member self.SymbolDirectories = - self.SymbolDirectories |> PrepareOptions.ToSeq + self.SymbolDirectories |> toSeq member self.Dependencies = - self.Dependencies |> PrepareOptions.ToSeq + self.Dependencies |> toSeq - member self.Keys = - self.Keys |> PrepareOptions.ToSeq + member self.Keys = self.Keys |> toSeq member self.StrongNameKey = self.StrongNameKey member self.Report = self.Report member self.FileFilter = - self.FileFilter |> PrepareOptions.ToSeq + self.FileFilter |> toSeq member self.AssemblyFilter = - self.AssemblyFilter |> PrepareOptions.ToSeq + self.AssemblyFilter |> toSeq member self.AssemblyExcludeFilter = - self.AssemblyExcludeFilter |> PrepareOptions.ToSeq + self.AssemblyExcludeFilter |> toSeq member self.TypeFilter = - self.TypeFilter |> PrepareOptions.ToSeq + self.TypeFilter |> toSeq member self.MethodFilter = - self.MethodFilter |> PrepareOptions.ToSeq + self.MethodFilter |> toSeq member self.AttributeFilter = - self.AttributeFilter |> PrepareOptions.ToSeq + self.AttributeFilter |> toSeq member self.PathFilter = - self.PathFilter |> PrepareOptions.ToSeq + self.PathFilter |> toSeq member self.AttributeTopLevel = - self.AttributeTopLevel |> PrepareOptions.ToSeq + self.AttributeTopLevel |> toSeq member self.TypeTopLevel = - self.TypeTopLevel |> PrepareOptions.ToSeq + self.TypeTopLevel |> toSeq member self.MethodTopLevel = - self.MethodTopLevel |> PrepareOptions.ToSeq + self.MethodTopLevel |> toSeq member self.CallContext = - self.CallContext |> PrepareOptions.ToSeq + self.CallContext |> toSeq member self.ReportFormat = self.ReportFormat member self.InPlace = self.InPlace @@ -508,7 +511,7 @@ module AltCover = member self.BranchCover = self.BranchCover member self.CommandLine = - self.CommandLine |> PrepareOptions.ToSeq + self.CommandLine |> toSeq member self.ExposeReturnCode = self.ExposeReturnCode @@ -528,14 +531,6 @@ module AltCover = member self.Portable = self.Portable #if RUNNER - static member private ValidateArray a f key = - PrepareOptions.ValidateArraySimple a (f key) - - static member private ValidateArraySimple a f = a |> Seq.iter (f >> ignore) - - static member private ValidateOptional f key x = - if x |> String.IsNullOrWhiteSpace |> not then - f key x |> ignore member private self.Consistent() = if self.LineCover && self.BranchCover then @@ -562,41 +557,35 @@ module AltCover = | _ -> false context - |> PrepareOptions.ToSeq + |> toSeq |> Seq.fold select false |> ignore try CommandLine.error <- [] - PrepareOptions.ValidateArray + validateArray self.InputDirectories CommandLine.validateDirectory "--inputDirectory" - PrepareOptions.ValidateArray - self.OutputDirectories - CommandLine.validatePath - "--outputDirectory" + validateArray self.OutputDirectories CommandLine.validatePath "--outputDirectory" - PrepareOptions.ValidateOptional + validateOptional CommandLine.validateStrongNameKey "--strongNameKey" self.StrongNameKey - PrepareOptions.ValidateOptional CommandLine.validatePath "--report" self.Report + validateOptional CommandLine.validatePath "--report" self.Report - PrepareOptions.ValidateArray + validateArray self.SymbolDirectories CommandLine.validateDirectory "--symbolDirectory" - PrepareOptions.ValidateArray - self.Dependencies - CommandLine.validateAssembly - "--dependency" + validateArray self.Dependencies CommandLine.validateAssembly "--dependency" - PrepareOptions.ValidateArray self.Keys CommandLine.validateStrongNameKey "--key" + validateArray self.Keys CommandLine.validateStrongNameKey "--key" [ self.FileFilter self.AssemblyFilter @@ -605,8 +594,7 @@ module AltCover = self.MethodFilter self.AttributeFilter self.PathFilter ] - |> Seq.iter (fun a -> - PrepareOptions.ValidateArraySimple a CommandLine.validateRegexes) + |> Seq.iter (fun a -> validateArraySimple a CommandLine.validateRegexes) self.Consistent() validateContext self.CallContext diff --git a/AltCover.Engine/CecilEx.fs b/AltCover.Engine/CecilEx.fs index e2b8e1bdb..e2a4b72c1 100644 --- a/AltCover.Engine/CecilEx.fs +++ b/AltCover.Engine/CecilEx.fs @@ -379,4 +379,12 @@ module internal CecilExtension = |> Seq.filter (fun i -> i.OpCode = OpCodes.Tail) |> Seq.iter (fun i -> i.OpCode <- OpCodes.Nop - i.Operand <- nullObject) \ No newline at end of file + i.Operand <- nullObject) + +[)", + Justification = "code inlined")>] +() \ No newline at end of file diff --git a/AltCover.Engine/Instrument.fs b/AltCover.Engine/Instrument.fs index a15e6403f..6b05a0875 100644 --- a/AltCover.Engine/Instrument.fs +++ b/AltCover.Engine/Instrument.fs @@ -82,8 +82,11 @@ type internal AsyncSupport = let wait = task.Methods - |> Seq.filter (fun f -> - f.FullName = "System.Boolean System.Threading.Tasks.Task::Wait(System.Int32)") + |> Seq.filter + _.FullName.Equals( + "System.Boolean System.Threading.Tasks.Task::Wait(System.Int32)", + StringComparison.Ordinal + ) |> Seq.head let def2 = @@ -95,7 +98,7 @@ type internal AsyncSupport = let runsynch = fsasync.Methods - |> Seq.filter (fun f -> f.Name = "RunSynchronously") + |> Seq.filter _.Name.Equals("RunSynchronously", StringComparison.Ordinal) |> Seq.head { TaskAssembly = def @@ -1479,32 +1482,6 @@ module internal Instrument = "PreferStringComparisonOverrideRule", Scope = "member", // MethodDefinition Target = - "AltCover.Instrument/I/tag@243::Invoke(System.String)", + "AltCover.Instrument/I/tag@246::Invoke(System.String)", Justification = "Replace override not available")>] -() - -(* - .field private static bool hit1 - - private static bool Ping(int s) - { - Console.WriteLine(s); - return true; - } - - // default false fields, release build - if (!hit1) hit1 = Ping(i); - - // loop start (head: IL_0031) - IL_0004: ldsfld bool ConsoleApp1.Program::hit1 - IL_0009: brtrue.s IL_0016 - - // hit1 = Ping(i); - IL_000b: ldloc.0 // i - IL_000c: call bool ConsoleApp1.Program::Ping(int32) - IL_0011: stsfld bool ConsoleApp1.Program::hit1 - - // int s = i + 10; - IL_0016: ldloc.0 - -*) \ No newline at end of file +() \ No newline at end of file diff --git a/AltCover.Engine/Main.fs b/AltCover.Engine/Main.fs index 80bbf8e7e..6f88c3de2 100644 --- a/AltCover.Engine/Main.fs +++ b/AltCover.Engine/Main.fs @@ -435,7 +435,9 @@ module internal Main = let internal matchType = Maybe - (System.Environment.GetEnvironmentVariable("OS") = "Windows_NT") + (System.Environment + .GetEnvironmentVariable("OS") + .Equals("Windows_NT", StringComparison.Ordinal)) StringComparison.OrdinalIgnoreCase StringComparison.Ordinal diff --git a/AltCover.Engine/NativeJson.fs b/AltCover.Engine/NativeJson.fs index 6476ec047..5e0f2d3c4 100644 --- a/AltCover.Engine/NativeJson.fs +++ b/AltCover.Engine/NativeJson.fs @@ -1474,8 +1474,7 @@ type internal DocumentType = [.$NativeJson.#.cctor()", + Target = "AltCover.NativeJson.#.cctor()", Justification = "Compiler Generated")>] #endif diff --git a/AltCover.Engine/PostProcess.fs b/AltCover.Engine/PostProcess.fs index f6d02eeca..fc863aeb1 100644 --- a/AltCover.Engine/PostProcess.fs +++ b/AltCover.Engine/PostProcess.fs @@ -515,4 +515,40 @@ module internal PostProcess = Target = "AltCover.PostProcess/Pipe #2 stage #1 at line 330@331-1::Invoke(AltCover.XmlElementAbstraction)", Justification = "Compiler generated")>] +[] +[] +[] +[] +[] +[] () \ No newline at end of file diff --git a/AltCover.Engine/Runner.fs b/AltCover.Engine/Runner.fs index 1d5dc1ce4..a65bee954 100644 --- a/AltCover.Engine/Runner.fs +++ b/AltCover.Engine/Runner.fs @@ -1542,4 +1542,16 @@ module internal Runner = Target = "AltCover.TeamCityFormat+Tags.#R", MessageId = "R", Justification = "TeamCity notation")>] +[)", + Justification = "Generated comparison")>] +[] () \ No newline at end of file diff --git a/AltCover.Engine/Visitor.fs b/AltCover.Engine/Visitor.fs index 56bddb8d9..c6e2ce833 100644 --- a/AltCover.Engine/Visitor.fs +++ b/AltCover.Engine/Visitor.fs @@ -267,6 +267,9 @@ module internal KeyStore = type internal Fix<'T> = delegate of 'T -> Fix<'T> [] +[] module internal CoverageParameters = let internal hash = System.Security.Cryptography.SHA256.Create() @@ -1194,11 +1197,11 @@ module internal Visitor = | _ -> seq let getSequencePoint (dbg: IDictionary) (i: Instruction) = - dbg.TryGetValue(i.Offset) |> snd + i.Offset |> dbg.TryGetValue |> snd let internal findEffectiveSequencePoint genuine - (dbg: Dictionary) + (dbg: IDictionary) (instructions: Instruction seq) = instructions @@ -1208,7 +1211,7 @@ module internal Visitor = |> Seq.tryFind isSequencePoint let internal findSequencePoint - (dbg: Dictionary) + (dbg: IDictionary) (instructions: Instruction seq) = findEffectiveSequencePoint Genuine dbg instructions @@ -1304,7 +1307,7 @@ module internal Visitor = else firstOfSequencePoint dbg p - let internal getJumps (dbg: Dictionary) (i: Instruction) = + let internal getJumps (dbg: IDictionary) (i: Instruction) = let terminal = lastOfSequencePoint dbg i let next = i.Next @@ -1404,7 +1407,7 @@ module internal Visitor = let private extractBranchPoints (v0t: TypeReference option) - (dbg: Dictionary) + (dbg: IDictionary) rawInstructions interesting vc @@ -1481,15 +1484,15 @@ module internal Visitor = Key = i })) |> Seq.choose id |> processBranches - |> Seq.map BranchPoint + |> Seq.map BranchPoint // AltCover.Visitor/I/Pipe #2 stage #10 |> Seq.toList let internal validateInstruction (dbg: IDictionary) (x: Instruction) = - let (_, s) = dbg.TryGetValue x.Offset - s.IsNotNull && (s.IsHidden |> not) + let (yes, s) = dbg.TryGetValue x.Offset + yes && (s.IsHidden |> not) let internal trivial = HashSet( @@ -1502,21 +1505,14 @@ module internal Visitor = ) let internal isNonTrivialSeqPnt - (dbg: Dictionary) + (dbg: IDictionary) (x: Instruction) = if CoverageParameters.trivia.Value then let rest = // rest of the sequence point Seq.unfold (fun (i: Instruction) -> - if - i |> isNull - || i.Offset - |> dbg.TryGetValue - |> snd - |> isNull - |> not - then + if i |> isNull || i.Offset |> dbg.ContainsKey then None else Some(i, i.Next)) @@ -1539,13 +1535,12 @@ module internal Visitor = let splut = Dictionary() do - let dbg = m.Method.DebugInformation - - if dbg.IsNotNull && dbg.HasSequencePoints then + m.Method.DebugInformation + |> Option.ofObj + |> Option.filter _.HasSequencePoints + |> Option.iter (fun dbg -> dbg.SequencePoints - |> Seq.iter (fun s -> splut.Add(s.Offset, s)) - - // build more look-up tables + |> Seq.iter (fun s -> splut.Add(s.Offset, s))) let instructions = [ rawInstructions |> Seq.cast ] @@ -1592,11 +1587,11 @@ module internal Visitor = else instructions.OrderByDescending(fun (x: Instruction) -> x.Offset) |> Seq.mapi (fun i x -> - let s = splut.TryGetValue(x.Offset) |> snd + let s = x.Offset |> splut.TryGetValue |> snd MethodPoint { Instruction = x - SeqPnt = s |> SeqPnt.Build |> Some + SeqPnt = s |> SeqPnt.Build |> Some // AltCover.Visitor/I/sp@1 Uid = i + point Interesting = wanted interesting s DefaultVisitCount = m.DefaultVisitCount }) @@ -1733,18 +1728,24 @@ module internal Visitor = "InstantiateArgumentExceptionCorrectlyRule", Scope = "member", // MethodDefinition Target = - "AltCover.Visitor/I/finish@1263::Invoke(Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Collections.FSharpList`1)", + "AltCover.Visitor/I/start@1263::Invoke(Microsoft.FSharp.Core.FSharpFunc`2,Microsoft.FSharp.Collections.FSharpList`1)", Justification = "Inlined library code")>] [] [] +[,Microsoft.FSharp.Collections.FSharpList`1)", Justification = "Inlined library code")>] () \ No newline at end of file diff --git a/AltCover.Fake/Fake.fs b/AltCover.Fake/Fake.fs index 521d5f93c..cde0e2875 100644 --- a/AltCover.Fake/Fake.fs +++ b/AltCover.Fake/Fake.fs @@ -152,6 +152,11 @@ module DotNet = Scope = "type", Target = "AltCoverFake.DotNet.Testing.DotNet", Justification = "That's life I'm afraid")>] +[] #endif [ Seq.find (fun a -> a.GetName().Name = "System.Management.Automation") + |> Seq.find (fun a -> + a + .GetName() + .Name.Equals("System.Management.Automation", StringComparison.Ordinal)) let acceleratorsType = sma.GetType("System.Management.Automation.TypeAccelerators") @@ -119,10 +122,10 @@ type AddAcceleratorCommand() = finalmap |> Seq.filter (fun kv -> (((self.Accelerator.IsPresent - && kv.Key = "accelerators" + && kv.Key.Equals("accelerators", StringComparison.Ordinal) && kv.Value = acceleratorsType) || (self.XDocument.IsPresent - && kv.Key = "xdoc" + && kv.Key.Equals("xdoc", StringComparison.Ordinal) && kv.Value = typeof)) |> not)) |> Seq.map (fun kv -> sprintf "%A = %A" kv.Key kv.Value.FullName) @@ -176,7 +179,10 @@ type GetAcceleratorCommand() = let sma = env - |> Seq.find (fun a -> a.GetName().Name = "System.Management.Automation") + |> Seq.find (fun a -> + a + .GetName() + .Name.Equals("System.Management.Automation", StringComparison.Ordinal)) let acceleratorsType = sma.GetType("System.Management.Automation.TypeAccelerators") diff --git a/AltCover.PowerShell/XhtmlReports.fs b/AltCover.PowerShell/XhtmlReports.fs index 1ec4714c2..8db848402 100644 --- a/AltCover.PowerShell/XhtmlReports.fs +++ b/AltCover.PowerShell/XhtmlReports.fs @@ -186,4 +186,12 @@ type ConvertToSourceMapCommand(outputFolder: String) = result |> self.WriteObject finally Directory.SetCurrentDirectory here -#endif \ No newline at end of file +#endif + +[] +() \ No newline at end of file diff --git a/AltCover.Toolkit/OpenCover.fs b/AltCover.Toolkit/OpenCover.fs index a8c5c1626..bf92e672a 100644 --- a/AltCover.Toolkit/OpenCover.fs +++ b/AltCover.Toolkit/OpenCover.fs @@ -1251,7 +1251,7 @@ coverlet on Tests.AltCoverRunnerTests/PostprocessShouldRestoreDegenerateOpenCove [] [.$Persistence.#.cctor()", Justification = "Compiler generated")>] +[] () \ No newline at end of file diff --git a/AltCover.Visualizer/Visualizer.fs b/AltCover.Visualizer/Visualizer.fs index 91bc4faa5..c7a557600 100644 --- a/AltCover.Visualizer/Visualizer.fs +++ b/AltCover.Visualizer/Visualizer.fs @@ -232,6 +232,9 @@ module private Gui = [] + [] type FileOpenDialog(dialog: FileChooserDialog) = member self.Run() = dialog.SetCurrentFolder(Persistence.readFolder ()) @@ -247,6 +250,9 @@ module private Gui = [] + [] member self.InitialDirectory with set (value) = dialog.SetCurrentFolder(value) |> ignore @@ -1031,6 +1037,11 @@ module private Gui = Target = ".$Visualizer.#.cctor()", Justification = "Compiler generated")>] +[] #if NET472 [ List.filter (fun x -> - let root = (snd x).Root - root.Name.LocalName = "CoverageSession") - |> List.filter (fun x -> - try - (snd x).Validate(opencoverStrict, null) - false - with :? XmlSchemaValidationException -> - true) - |> List.map fst - - let o2expect = - [ // embeds - "_ApiUse/_DotnetTest/coverage.xml" - "_DotnetTestJson/coverage.xml" - "_Issue114/coverage.xml" - "_Reports/ApiTestWithAltCoverCoreRunner.net9.0.xml" - "_Reports/DotnetGlobalIntegration.xml" - "_Reports/MonitorTestWithAltCoverCoreRunner.net9.0.xml" - "_Reports/ValidateGendarmeEmulationUnitTestWithAltCoverCoreRunner.net9.0.xml" - "_Reports/RecorderTestWithAltCoverCoreRunner.net9.0.xml" - "_Reports/VisualizerTestWithAltCoverCoreRunner.net9.0.xml" - "_DotnetTest/coverage.xml" - "_Binaries/_DotnetGlobalTest/Debug+AnyCPU/net9.0/DotnetGlobalIntegration.xml" - "_Cake/_DotnetTest/coverage.build.cake.--version 4.0.0.xml" - "_Cake/_DotnetTest/coverage.build.cake.Latest.xml" - "_DotnetTestFail/coverage.xml" - "_DotnetTestFailFast/coverage.xml" - "_DotnetTestFailFastInPlace/coverage.xml" - "_DotnetTestFailInPlace/coverage.xml" - "_DotnetTestInPlace/coverage.xml" - "__AltCover.Api.Tests/OpenCover.xml" - "AltCover.Api.Tests/OpenCover.xml" - "_DotnetTestBranchCover/coverage.xml" - "_DotnetTestBranchCoverInPlace/coverage.xml" - "_DotnetTestLineCover/coverage.xml" - "_DotnetTestLineCoverInPlace/coverage.xml" - "_Issue23/coverage.xml" - "_Issue67/coverage.xml" - "AltCover.Tests/HandRolledMonoCoverage.xml" - "AltCover.Tests/OpenCoverWithEmbeds.xml" - "AltCover.Tests/OpenCoverWithPartials.xml" - "AltCover.Tests/Sample4FullTracking.xml" - "_Reports/AltCoverAsyncAwaitTests.xml" - "_Reports/Pester.xml" - "_Reports/RawPester.xml" - "RegressionTesting/issue37/coverage.xml" - "Samples/Sample16/Test/_Issue72/combined.Test.xml" - "Samples/Sample16/Test/_Issue72/original.Test.xml" - "Samples/Sample16/Test/_Issue72/single.Test.xml" - "Samples/Sample16/Test/_Reports/solution.Test.xml" - "Samples/Sample16/Test/_Reports/single.Test.xml" - "Samples/Sample16/Test/_Reports/solution.Test2.xml" - // coverlet - "Samples/Sample32/coverlet.opencover.6.0.2.xml" - "AltCover.Api.Tests/OpenCoverForPester.coverlet.xml" - "AltCover.Tests/OpenCoverForPester.coverlet.expected.xml" - "__AltCover.Api.Tests/OpenCoverForPester.coverlet.xml" - "AltCover.Tests/Sample21.coverage.opencover.xml" - "AltCover.Tests/Sample4.coverlet.xml" ] - @ if Environment.isWindows then - [ "_Issue156/Tests/coverage.xml" ] - else - [] - - let o3expect = // embeds - !!(@"./**/JsonWithPartials*Xml.xml") |> Seq.toList - - let o4expect = // coverlet - !!(@"./_Reports/**/*.coverlet.xml") |> Seq.toList - - let o5expect = // coverlet - !!(@"./**/coverage.opencover.xml") |> Seq.toList - - let oexpect = - [ o1expect - o2expect - o3expect - o4expect - o5expect ] - |> List.concat - |> List.map Path.getFullName - |> List.filter File.Exists - - Assert.That(opencover2Files, Is.EquivalentTo oexpect, "opencover2Files") - let issue71 = !!(@"./**/*.exn") |> Seq.toList diff --git a/bootstrap.ps1 b/bootstrap.ps1 new file mode 100644 index 000000000..6b1132a25 --- /dev/null +++ b/bootstrap.ps1 @@ -0,0 +1,3 @@ +dotnet tool restore +dotnet run --project .\Build\setup.fsproj +dotnet run --project .\Build\build.fsproj --target Compilation \ No newline at end of file diff --git a/global.json b/global.json index 42b8acba7..1d866f004 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100-preview.6.24328.19", + "version": "9.0.100-preview.7.24407.12", "rollForward": "latestMinor" } } \ No newline at end of file