Skip to content

Commit

Permalink
allow paket to omit similar warnings (ie group warnings).
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Aug 21, 2017
1 parent ba0cb05 commit afbe69d
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 9 deletions.
21 changes: 21 additions & 0 deletions src/Paket.Core/Common/Logging.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
open System
open System.IO
open System.Diagnostics
open System.Collections.Concurrent
open System.Threading

/// [omit]
let mutable verbose = false
Expand Down Expand Up @@ -49,6 +51,25 @@ let traceErrorfn fmt = Printf.ksprintf traceError fmt
/// [omit]
let traceWarnfn fmt = Printf.ksprintf traceWarn fmt

let private omittedWarnings = ref 0
let private warnings = ConcurrentDictionary<obj,Guid>()
let traceIfNotBefore tracer key fmt =
let printer =
if verbose then tracer
else
let g = Guid.NewGuid()
if g = warnings.GetOrAdd(key, fun _ -> g) then
tracer
else
Interlocked.Increment(omittedWarnings) |> ignore
ignore

Printf.ksprintf printer fmt

let getOmittedWarningCount () = omittedWarnings.Value

let traceWarnIfNotBefore key fmt = traceIfNotBefore traceWarn key fmt
let traceErrorIfNotBefore key fmt = traceIfNotBefore traceError key fmt

// Console Trace

Expand Down
4 changes: 4 additions & 0 deletions src/Paket.Core/Common/Logging.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ val traceErrorfn : Printf.StringFormat<'a,unit> -> 'a

val traceWarnfn : Printf.StringFormat<'a,unit> -> 'a

val traceWarnIfNotBefore : 'a -> Printf.StringFormat<'b,unit> -> 'b
val traceErrorIfNotBefore : 'a -> Printf.StringFormat<'b,unit> -> 'b

val getOmittedWarningCount : unit -> int

type Trace = {
Level: TraceLevel
Expand Down
2 changes: 2 additions & 0 deletions src/Paket.Core/Dependencies/NuGetCache.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type NuGetRequestGetVersions =
type UnparsedPackageFile =
{ FullPath : string
PathWithinPackage : string }
member x.BasePath =
x.FullPath.Substring(0, x.FullPath.Length - (x.PathWithinPackage.Length + 1))

module NuGetConfig =
open System.Text
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Dependencies/NuGetV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ let private handleODataEntry nugetURL packageName version entry =
match PlatformMatching.extractPlatforms false restriction with
| Some p -> Some p
| None ->
Logging.traceWarnfn "Could not detect any platforms from '%s' in package %O %O" restriction packageName version
Logging.traceWarnIfNotBefore ("Package", restriction, packageName, version) "Could not detect any platforms from '%s' in package %O %O, please tell the package authors" restriction packageName version
None
else Some PlatformMatching.ParsedPlatformPath.Empty)
|> Option.map (fun pp -> name, version, pp)
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Dependencies/NuGetV3.fs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ let getPackageDetails (source:NugetV3Source) (packageName:PackageName) (version:
| x ->
let restrictions, problems = Requirements.parseRestrictionsLegacy false x
for problem in problems do
Logging.traceErrorfn "Could not detect any platforms from '%s' in %O %O" problem.Framework packageName version
Logging.traceErrorIfNotBefore ("Package", problem.Framework, packageName, version) "Could not detect any platforms from '%s' in %O %O, please tell the package authors" problem.Framework packageName version
restrictions
(PackageName dep.Id), (VersionRequirement.Parse dep.Range), targetFramework)
|> Seq.toList
Expand Down
4 changes: 2 additions & 2 deletions src/Paket.Core/Dependencies/Nuspec.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module internal NuSpecParserHelper =
match PlatformMatching.extractPlatforms false framework with
| Some pp -> Some (name, version, pp)
| None ->
Logging.traceWarnfn "Could not detect any platforms from '%s' in '%s'" framework fileName
Logging.traceWarnIfNotBefore ("NuSpecFile", framework, fileName) "Could not detect any platforms from '%s' in '%s', please tell the package authors" framework fileName
None
| _ -> Some(name,version, PlatformMatching.ParsedPlatformPath.Empty)

Expand Down Expand Up @@ -84,7 +84,7 @@ type Nuspec =
match PlatformMatching.extractPlatforms false framework with
| Some p -> Some p
| None ->
Logging.traceWarnfn "Could not detect any platforms from '%s' in '%s'" framework fileName
Logging.traceWarnIfNotBefore ("NuSpecFile", framework, fileName) "Could not detect any platforms from '%s' in '%s', please tell the package authors" framework fileName
None
| _ -> Some PlatformMatching.ParsedPlatformPath.Empty)

Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/PackageManagement/NugetConvert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ let createDependenciesFileR (rootDirectory : DirectoryInfo) nugetEnv mode =
|> List.map (fun fw ->
let restrictions, problems = Requirements.parseRestrictionsLegacy false fw
for problem in problems do
Logging.traceErrorfn "Could not detect any platforms from '%s' in %O %O" problem.Framework name version
Logging.traceErrorfn "Could not detect any platforms from '%s' in %O %O, please tell the package authors" problem.Framework name version
restrictions)
| _ -> []
let restrictions =
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/PaketConfigFiles/InstallModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ module InstallModel =
(FolderScanner.choose "invalid tfm" (fun plats ->
let parsed = PlatformMatching.extractPlatforms false plats
if parsed.IsNone then
traceWarnfn "Could not detect any platforms from '%s' in '%s'" plats upf.FullPath
traceWarnIfNotBefore ("File", plats, upf.BasePath) "Could not detect any platforms from '%s' in '%s', please tell the package authors" plats upf.FullPath
parsed)) >> FolderScanner.ParseResult.box) }
{ FolderScanner.AdvancedScanner.Name = "rid";
FolderScanner.AdvancedScanner.Parser =
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Versioning/PlatformMatching.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let extractPlatforms warn path =
match extractPlatformsPriv path with
| None ->
if warn then
traceWarnfn "Could not detect any platforms from '%s'" path
Logging.traceWarnIfNotBefore ("extractPlatforms", path) "Could not detect any platforms from '%s', please tell the package authors" path
None
| Some s -> Some s

Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartAction>Project</StartAction>
<StartArguments>restore</StartArguments>
<StartWorkingDirectory>C:\temp\perf\</StartWorkingDirectory>
<StartArguments>update</StartArguments>
<StartWorkingDirectory>C:\proj\testing\testpaketfailure\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
Expand Down
3 changes: 3 additions & 0 deletions src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ let processWithValidation silent validateF commandF (result : ParseResults<'T>)
)

tracefn " - Runtime: %s" (Utils.TimeSpanToReadableString realTime)
let omitted = Logging.getOmittedWarningCount()
if not verbose && omitted > 0 then
traceWarnfn "Paket omitted '%d' warnings similar to the ones above. You can see them in verbose mode" omitted

let processCommand silent commandF result =
processWithValidation silent (fun _ -> true) commandF result
Expand Down

0 comments on commit afbe69d

Please sign in to comment.