Skip to content

Commit d26de72

Browse files
authored
Merge pull request #3616 from KevinRansom/vs2017-rtm
merge master into vs2017-rtm
2 parents 8615245 + 2b13f5d commit d26de72

File tree

7 files changed

+183
-69
lines changed

7 files changed

+183
-69
lines changed

build.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ if "%OSARCH%"=="AMD64" set SYSWOW64=SysWoW64
639639

640640
if not "%OSARCH%"=="x86" set REGEXE32BIT=%WINDIR%\syswow64\reg.exe
641641

642-
echo SDK environment vars from Registry
642+
echo SDK environment vars from Registry (note: ignore "ERROR: The system was unable to find ....")
643643
echo ==================================
644644
FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
645645
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B

src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs

+37-27
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,21 @@ open Printf
341341

342342
let generateResxAndSource (filename:string) =
343343
try
344-
let printMessage message = printfn "FSharpEmbedResourceText: %s" message
345-
let justfilename = Path.GetFileNameWithoutExtension(filename) // .txt
346-
if justfilename |> Seq.exists (System.Char.IsLetterOrDigit >> not) then
347-
Err(filename, 0, sprintf "The filename '%s' is not allowed; only letters and digits can be used, as the filename also becomes the namespace for the SR class" justfilename)
348-
let outFilename = Path.Combine(_outputPath, justfilename + ".fs")
349-
let outXmlFilename = Path.Combine(_outputPath, justfilename + ".resx")
344+
let printMessage message = printfn "FSharpEmbedResourceText: %s" message
345+
let justfilename = Path.GetFileNameWithoutExtension(filename) // .txt
346+
if justfilename |> Seq.exists (System.Char.IsLetterOrDigit >> not) then
347+
Err(filename, 0, sprintf "The filename '%s' is not allowed; only letters and digits can be used, as the filename also becomes the namespace for the SR class" justfilename)
348+
let outFilename = Path.Combine(_outputPath, justfilename + ".fs")
349+
let outXmlFilename = Path.Combine(_outputPath, justfilename + ".resx")
350+
351+
if File.Exists(outFilename) &&
352+
File.Exists(outXmlFilename) &&
353+
File.Exists(filename) &&
354+
File.GetLastWriteTime(filename) <= File.GetLastWriteTime(outFilename) &&
355+
File.GetLastWriteTime(filename) <= File.GetLastWriteTime(outXmlFilename) then
356+
printMessage (sprintf "Skipping generation of %s and %s since up-to-date" outFilename outXmlFilename)
357+
Some (outFilename, outXmlFilename)
358+
else
350359

351360
printMessage (sprintf "Reading %s" filename)
352361
let lines = File.ReadAllLines(filename)
@@ -472,27 +481,28 @@ open Printf
472481
with get() = _hostObject
473482
and set(value) = _hostObject <- value
474483
member this.Execute() =
475-
let sourceItem (source:string) (originalItem:string) =
476-
let item = TaskItem(source)
477-
item.SetMetadata("AutoGen", "true")
478-
item.SetMetadata("DesignTime", "true")
479-
item.SetMetadata("DependentUpon", originalItem)
480-
item :> ITaskItem
481-
let resxItem (resx:string) =
482-
let item = TaskItem(resx)
483-
item.SetMetadata("ManifestResourceName", Path.GetFileNameWithoutExtension(resx))
484-
item :> ITaskItem
485-
let generatedFiles, generatedResult =
484+
485+
let generatedFiles =
486486
this.EmbeddedText
487-
|> Array.fold (fun (resultList, aggregateResult) item ->
488-
match generateResxAndSource item.ItemSpec with
489-
| Some (source, resx) -> (((source, resx) :: resultList), aggregateResult)
490-
| None -> (resultList, false)
491-
) ([], true)
487+
|> Array.choose (fun item -> generateResxAndSource item.ItemSpec)
488+
492489
let generatedSource, generatedResx =
493-
generatedFiles
494-
|> List.map (fun (source, resx) -> (sourceItem source resx, resxItem resx))
495-
|> List.fold (fun (sources, resxs) (source, resx) -> (source :: sources, resx:: resxs)) ([], [])
496-
_generatedSource <- generatedSource |> List.rev |> List.toArray
497-
_generatedResx <- generatedResx |> List.rev |> List.toArray
490+
[| for (source, resx) in generatedFiles do
491+
let sourceItem =
492+
let item = TaskItem(source)
493+
item.SetMetadata("AutoGen", "true")
494+
item.SetMetadata("DesignTime", "true")
495+
item.SetMetadata("DependentUpon", resx)
496+
item :> ITaskItem
497+
let resxItem =
498+
let item = TaskItem(resx)
499+
item.SetMetadata("ManifestResourceName", Path.GetFileNameWithoutExtension(resx))
500+
item :> ITaskItem
501+
yield (sourceItem, resxItem) |]
502+
|> Array.unzip
503+
504+
let generatedResult = (generatedFiles.Length = this.EmbeddedText.Length)
505+
506+
_generatedSource <- generatedSource
507+
_generatedResx <- generatedResx
498508
generatedResult

src/fsharp/FSharp.Build/Fsc.fs

+8-5
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
158158
let mutable subsystemVersion : string = null
159159
let mutable tailcalls : bool = true
160160
let mutable targetProfile : string = null
161-
let mutable targetType : string = null
161+
let mutable targetType : string = null
162162
let mutable toolExe : string = "fsc.exe"
163163
let mutable toolPath : string =
164164
let locationOfThisDll =
@@ -277,7 +277,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
277277
| "WINEXE" -> "winexe"
278278
| "MODULE" -> "module"
279279
| _ -> null)
280-
280+
281281
// NoWarn
282282
match disabledWarnings with
283283
| null -> ()
@@ -418,7 +418,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
418418
// --noframework
419419
member fsc.NoFramework
420420
with get() = noFramework
421-
and set(b) = noFramework <- b
421+
and set(b) = noFramework <- b
422422

423423
// --optimize
424424
member fsc.Optimize
@@ -543,7 +543,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
543543
member fsc.Win32ManifestFile
544544
with get() = win32manifest
545545
and set(m) = win32manifest <- m
546-
546+
547547
// For specifying the warning level (0-4)
548548
member fsc.WarningLevel
549549
with get() = warningLevel
@@ -552,7 +552,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
552552
member fsc.WarningsAsErrors
553553
with get() = warningsAsErrors
554554
and set(s) = warningsAsErrors <- s
555-
555+
556556
member fsc.VisualStudioStyleErrors
557557
with get() = vserrors
558558
and set(p) = vserrors <- p
@@ -581,6 +581,9 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
581581
override fsc.GenerateFullPathToTool() =
582582
if toolPath = "" then raise (new System.InvalidOperationException(FSBuild.SR.toolpathUnknown()))
583583
System.IO.Path.Combine(toolPath, fsc.ToolExe)
584+
override fsc.LogToolCommand (message:string) =
585+
fsc.Log.LogMessageFromText(message, MessageImportance.Normal) |>ignore
586+
584587
member internal fsc.InternalGenerateFullPathToTool() = fsc.GenerateFullPathToTool() // expose for unit testing
585588
member internal fsc.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands) = // F# does not allow protected members to be captured by lambdas, this is the standard workaround
586589
base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands)

src/fsharp/TypeChecker.fs

+4
Original file line numberDiff line numberDiff line change
@@ -5310,6 +5310,8 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
53105310
checkNoArgsForLiteral()
53115311
UnifyTypes cenv env m ty (finfo.FieldType(cenv.amap, m))
53125312
let c' = TcFieldInit m lit
5313+
let item = Item.ILField(finfo)
5314+
CallNameResolutionSink cenv.tcSink (m, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Pattern, env.DisplayEnv, env.AccessRights)
53135315
(fun _ -> TPat_const (c', m)), (tpenv, names, takenNames)
53145316

53155317
| Item.RecdField rfinfo ->
@@ -5337,6 +5339,8 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p
53375339
CheckFSharpAttributes cenv.g vref.Attribs m |> CommitOperationResult
53385340
checkNoArgsForLiteral()
53395341
UnifyTypes cenv env m ty vexpty
5342+
let item = Item.Value(vref)
5343+
CallNameResolutionSink cenv.tcSink (m, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Pattern, env.DisplayEnv, env.AccessRights)
53405344
(fun _ -> TPat_const (lit, m)), (tpenv, names, takenNames)
53415345

53425346
| _ -> error (Error(FSComp.SR.tcRequireVarConstRecogOrLiteral(), m))

tests/service/EditorTests.fs

+96
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,103 @@ let test3 = System.Text.RegularExpressions.RegexOptions.Compiled
613613
]
614614
|]
615615

616+
[<Test>]
617+
let ``IL enum fields should be reported`` () =
618+
let input =
619+
"""
620+
open System
621+
622+
let _ =
623+
match ConsoleKey.Tab with
624+
| ConsoleKey.OemClear -> ConsoleKey.A
625+
| _ -> ConsoleKey.B
626+
"""
627+
628+
let file = "/home/user/Test.fsx"
629+
let _, typeCheckResults = parseAndCheckScript(file, input)
630+
typeCheckResults.GetAllUsesOfAllSymbolsInFile()
631+
|> Async.RunSynchronously
632+
|> Array.map (fun su ->
633+
let r = su.RangeAlternate
634+
su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn))
635+
|> shouldEqual
636+
[|("ConsoleKey", (5, 10, 5, 20))
637+
("field Tab", (5, 10, 5, 24))
638+
("ConsoleKey", (6, 6, 6, 16))
639+
("field OemClear", (6, 6, 6, 25))
640+
("ConsoleKey", (6, 29, 6, 39))
641+
("field A", (6, 29, 6, 41))
642+
("ConsoleKey", (7, 11, 7, 21))
643+
("field B", (7, 11, 7, 23))
644+
("Test", (1, 0, 1, 0))|]
616645

646+
[<Test>]
647+
let ``Literal values should be reported`` () =
648+
let input =
649+
"""
650+
module Module1 =
651+
let [<Literal>] ModuleValue = 1
652+
653+
let _ =
654+
match ModuleValue + 1 with
655+
| ModuleValue -> ModuleValue + 2
656+
| _ -> 0
657+
658+
type Class1() =
659+
let [<Literal>] ClassValue = 1
660+
static let [<Literal>] StaticClassValue = 2
661+
662+
let _ = ClassValue
663+
let _ = StaticClassValue
664+
665+
let _ =
666+
match ClassValue + StaticClassValue with
667+
| ClassValue -> ClassValue + 1
668+
| StaticClassValue -> StaticClassValue + 2
669+
| _ -> 3
670+
"""
671+
672+
let file = "/home/user/Test.fsx"
673+
let _, typeCheckResults = parseAndCheckScript(file, input)
674+
typeCheckResults.GetAllUsesOfAllSymbolsInFile()
675+
|> Async.RunSynchronously
676+
|> Array.map (fun su ->
677+
let r = su.RangeAlternate
678+
su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn))
679+
|> shouldEqual
680+
[|("LiteralAttribute", (3, 10, 3, 17))
681+
("LiteralAttribute", (3, 10, 3, 17))
682+
("member .ctor", (3, 10, 3, 17))
683+
("val ModuleValue", (3, 20, 3, 31))
684+
("val op_Addition", (6, 26, 6, 27))
685+
("val ModuleValue", (6, 14, 6, 25))
686+
("val ModuleValue", (7, 10, 7, 21))
687+
("val op_Addition", (7, 37, 7, 38))
688+
("val ModuleValue", (7, 25, 7, 36))
689+
("Module1", (2, 7, 2, 14))
690+
("Class1", (10, 5, 10, 11))
691+
("member .ctor", (10, 5, 10, 11))
692+
("LiteralAttribute", (11, 10, 11, 17))
693+
("LiteralAttribute", (11, 10, 11, 17))
694+
("member .ctor", (11, 10, 11, 17))
695+
("val ClassValue", (11, 20, 11, 30))
696+
("LiteralAttribute", (12, 17, 12, 24))
697+
("LiteralAttribute", (12, 17, 12, 24))
698+
("member .ctor", (12, 17, 12, 24))
699+
("val StaticClassValue", (12, 27, 12, 43))
700+
("val ClassValue", (14, 12, 14, 22))
701+
("val StaticClassValue", (15, 12, 15, 28))
702+
("val op_Addition", (18, 25, 18, 26))
703+
("val ClassValue", (18, 14, 18, 24))
704+
("val StaticClassValue", (18, 27, 18, 43))
705+
("val ClassValue", (19, 10, 19, 20))
706+
("val op_Addition", (19, 35, 19, 36))
707+
("val ClassValue", (19, 24, 19, 34))
708+
("val StaticClassValue", (20, 10, 20, 26))
709+
("val op_Addition", (20, 47, 20, 48))
710+
("val StaticClassValue", (20, 30, 20, 46))
711+
("member .cctor", (10, 5, 10, 11))
712+
("Test", (1, 0, 1, 0))|]
617713

618714
//-------------------------------------------------------------------------------
619715

vsintegration/src/FSharp.ProjectSystem.Base/Project/IDEBuildLogger.cs

+36-35
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private void BuildStartedHandler(object sender, BuildStartedEventArgs buildEvent
358358
try
359359
{
360360
this.haveCachedRegistry = false;
361-
if (LogAtImportance(MessageImportance.Low))
361+
if (LogAtImportance(MessageImportance.Normal))
362362
{
363363
LogEvent(sender, buildEvent);
364364
}
@@ -385,7 +385,7 @@ private void BuildFinishedHandler(object sender, BuildFinishedEventArgs buildEve
385385
{
386386
try
387387
{
388-
if (LogAtImportance(buildEvent.Succeeded ? MessageImportance.Low :
388+
if (LogAtImportance(buildEvent.Succeeded ? MessageImportance.Normal :
389389
MessageImportance.High))
390390
{
391391
if (this.outputWindowPane != null)
@@ -408,7 +408,7 @@ private void ProjectStartedHandler(object sender, ProjectStartedEventArgs buildE
408408
{
409409
try
410410
{
411-
if (LogAtImportance(MessageImportance.Low))
411+
if (LogAtImportance(MessageImportance.Normal))
412412
{
413413
LogEvent(sender, buildEvent);
414414
}
@@ -427,7 +427,7 @@ private void ProjectFinishedHandler(object sender, ProjectFinishedEventArgs buil
427427
{
428428
try
429429
{
430-
if (LogAtImportance(buildEvent.Succeeded ? MessageImportance.Low
430+
if (LogAtImportance(buildEvent.Succeeded ? MessageImportance.Normal
431431
: MessageImportance.High))
432432
{
433433
LogEvent(sender, buildEvent);
@@ -473,7 +473,7 @@ private void TargetFinishedHandler(object sender, TargetFinishedEventArgs buildE
473473
{
474474
--this.currentIndent;
475475
if ((isLogTaskDone) &&
476-
LogAtImportance(buildEvent.Succeeded ? MessageImportance.Low
476+
LogAtImportance(buildEvent.Succeeded ? MessageImportance.Normal
477477
: MessageImportance.High))
478478
{
479479
LogEvent(sender, buildEvent);
@@ -556,36 +556,37 @@ private void CustomHandler(object sender, CustomBuildEventArgs buildEvent)
556556
/// This method takes a MessageImportance and returns true if messages
557557
/// at importance i should be loggeed. Otherwise return false.
558558
/// </summary>
559-
private bool LogAtImportance(MessageImportance importance)
560-
{
561-
// If importance is too low for current settings, ignore the event
562-
bool logIt = false;
563-
564-
this.SetVerbosity();
565-
566-
switch (this.Verbosity)
567-
{
568-
case LoggerVerbosity.Quiet:
569-
logIt = false;
570-
break;
571-
case LoggerVerbosity.Minimal:
572-
logIt = (importance == MessageImportance.High);
573-
break;
574-
case LoggerVerbosity.Normal:
575-
// Falling through...
576-
case LoggerVerbosity.Detailed:
577-
logIt = (importance != MessageImportance.Low);
578-
break;
579-
case LoggerVerbosity.Diagnostic:
580-
logIt = true;
581-
break;
582-
default:
583-
Debug.Fail("Unknown Verbosity level. Ignoring will cause everything to be logged");
584-
break;
585-
}
586-
587-
return logIt;
588-
}
559+
private bool LogAtImportance(MessageImportance importance)
560+
{
561+
// If importance is too low for current settings, ignore the event
562+
bool logIt = false;
563+
564+
this.SetVerbosity();
565+
566+
switch (this.Verbosity)
567+
{
568+
case LoggerVerbosity.Quiet:
569+
logIt = false;
570+
break;
571+
case LoggerVerbosity.Minimal:
572+
logIt = (importance == MessageImportance.High);
573+
break;
574+
case LoggerVerbosity.Normal:
575+
logIt = (importance == MessageImportance.Normal) || (importance == MessageImportance.High);
576+
break;
577+
case LoggerVerbosity.Detailed:
578+
logIt = (importance == MessageImportance.Low) || (importance == MessageImportance.Normal) || (importance == MessageImportance.High);
579+
break;
580+
case LoggerVerbosity.Diagnostic:
581+
logIt = true;
582+
break;
583+
default:
584+
Debug.Fail("Unknown Verbosity level. Ignoring will cause everything to be logged");
585+
break;
586+
}
587+
588+
return logIt;
589+
}
589590

590591
/// <summary>
591592
/// This is the method that does the main work of logging an event

vsintegration/src/FSharp.ProjectSystem.FSharp/ProjectSystem.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<PropertyGroup>
4343
<Win32Resource>$(IntermediateOutputPath)\ProjectResources.rc.res</Win32Resource>
4444
</PropertyGroup>
45-
<Target Name="BeforeBuild">
45+
<Target Name="BeforeBuild" Condition="!Exists('$(IntermediateOutputPath)$(RCResourceFile).res')">
4646
<Exec Command="&quot;$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)" Condition="Exists('$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe')" />
4747
<Exec Command="&quot;$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)" Condition="Exists('$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe')" />
4848
<Exec Command="&quot;$(ProgramFiles)\Windows Kits\10\bin\10.0.15063.0\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)" Condition="Exists('$(ProgramFiles)\Windows Kits\10\bin\10.0.15063.0\x86\rc.exe')" />

0 commit comments

Comments
 (0)