Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf1a8978

Browse files
auduchinokKevinRansom
authored andcommitted
Report builder creation warnings according to compiler args (#4125)
* Filter incremental builder creation errors according to compiler args* Fix CompilationErrorLogger ignores WarsAsError options* Add test for WarnAsError* Cleanup* Add more tests; cover WarnAsError-, no warnings at all* Refactor tests* Add test
1 parent8e0928d commitf1a8978

File tree

4 files changed

+50
-7
lines changed

4 files changed

+50
-7
lines changed

‎src/fsharp/service/IncrementalBuild.fs‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,8 +1703,11 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput
17031703
cancellable{
17041704

17051705
// Trap and report warnings and errors from creation.
1706-
use errorScope=new ErrorScope()
1707-
let!builderOpt=
1706+
letdelayedLogger= CapturingErrorLogger("IncrementalBuilderCreation")
1707+
use _unwindEL= PushErrorLoggerPhaseUntilUnwind(fun _-> delayedLogger)
1708+
use _unwindBP= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
1709+
1710+
let!builderOpt=
17081711
cancellable{
17091712
try
17101713

@@ -1814,7 +1817,18 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput
18141817
return None
18151818
}
18161819

1817-
return builderOpt, errorScope.Diagnostics
1820+
letdiagnostics=
1821+
match builderOptwith
1822+
| Some builder->
1823+
leterrorSeverityOptions= builder.TcConfig.errorSeverityOptions
1824+
leterrorLogger= CompilationErrorLogger("IncrementalBuilderCreation", errorSeverityOptions)
1825+
delayedLogger.CommitDelayedDiagnostics(errorLogger)
1826+
errorLogger.GetErrors()|> List.map(fun(d,severity)-> d, severity= FSharpErrorSeverity.Error)
1827+
|_->
1828+
delayedLogger.Diagnostics
1829+
|> List.map(fun(d,isError)-> FSharpErrorInfo.CreateFromException(d, isError, range.Zero))
1830+
1831+
return builderOpt, diagnostics
18181832
}
18191833
static memberKeepBuilderAlive(builderOpt:IncrementalBuilder option)=
18201834
match builderOptwith

‎src/fsharp/symbols/SymbolHelpers.fs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,14 @@ type internal CompilationErrorLogger (debugName: string, options: FSharpErrorSev
150150

151151
overridex.DiagnosticSink(exn,isError)=
152152
if isError|| ReportWarningAsError options exnthen
153-
diagnostics.Add(exn,isError)
153+
diagnostics.Add(exn,FSharpErrorSeverity.Error)
154154
errorCount<- errorCount+1
155155
elseif ReportWarning options exnthen
156-
diagnostics.Add(exn,isError)
156+
diagnostics.Add(exn,FSharpErrorSeverity.Warning)
157157

158158
overridex.ErrorCount= errorCount
159159

160-
memberx.GetErrors()=
161-
[for(e, isError)in diagnostics-> e,(if isErrorthen FSharpErrorSeverity.Errorelse FSharpErrorSeverity.Warning)]
160+
memberx.GetErrors()= List.ofSeq diagnostics
162161

163162

164163
/// This represents the global state established as each task function runs as part of the build.

‎tests/service/Common.fs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ let mkProjectCommandLineArgsForScript (dllName, fileNames) =
160160
|]
161161
#endif
162162

163+
letmkTestFileAndOptions source additionalArgs=
164+
letfileName= Path.ChangeExtension(Path.GetTempFileName(),".fs")
165+
letproject= Path.GetTempFileName()
166+
letdllName= Path.ChangeExtension(project,".dll")
167+
letprojFileName= Path.ChangeExtension(project,".fsproj")
168+
letfileSource1="module M"
169+
File.WriteAllText(fileName, fileSource1)
170+
171+
letargs= Array.append(mkProjectCommandLineArgs(dllName,[fileName])) additionalArgs
172+
letoptions= checker.GetProjectOptionsFromCommandLineArgs(projFileName, args)
173+
fileName, options
174+
175+
letparseAndCheckFile fileName source options=
176+
match checker.ParseAndCheckFileInProject(fileName,0, source, options)|> Async.RunSynchronouslywith
177+
| parseResults, FSharpCheckFileAnswer.Succeeded(checkResults)-> parseResults, checkResults
178+
|_-> failwithf"Parsing aborted unexpectedly..."
179+
163180
letparseAndCheckScript(file,input)=
164181

165182
#if DOTNETCORE

‎tests/service/ProjectAnalysisTests.fs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,3 +5195,16 @@ type A(i:int) =
51955195

51965196
| Some decl-> failwithf"unexpected declaration%A" decl
51975197
| None-> failwith"declaration list is empty"
5198+
5199+
5200+
[<TestCase(([||]: string[]),([||]: bool[]))>]
5201+
[<TestCase([|"--times"|],[|false|])>]
5202+
[<TestCase([|"--times";"--nowarn:75"|],([||]: bool[]))>]
5203+
[<TestCase([|"--times";"--warnaserror:75"|],[|true|])>]
5204+
[<TestCase([|"--times";"--warnaserror-:75";"--warnaserror"|],[|false|])>]
5205+
let ``#4030,Incremental builder creation warnings``(args,errorSeverities)=
5206+
letsource="module M"
5207+
letfileName,options= mkTestFileAndOptions source args
5208+
5209+
let_,checkResults= parseAndCheckFile fileName source options
5210+
checkResults.Errors|> Array.map(fun e-> e.Severity= FSharpErrorSeverity.Error)|> shouldEqual errorSeverities

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp