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

Commit2b13f5d

Browse files
committed
Merge branch 'master' ofhttps://github.com/microsoft/visualfsharp into vs2017-rtm
2 parents8615245 +b48f924 commit2b13f5d

File tree

7 files changed

+183
-69
lines changed

7 files changed

+183
-69
lines changed

‎build.cmd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ if "%OSARCH%"=="AMD64" set SYSWOW64=SysWoW64
639639

640640
ifnot"%OSARCH%"=="x86"setREGEXE32BIT=%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="%%AIN ('%REGEXE32BIT%QUERY"HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2\WinSDK-NetFx40Tools" /v InstallationFolder')DOSETWINSDKNETFXTOOLS=%%B
645645
if"%WINSDKNETFXTOOLS%"==""FOR /F"tokens=2* delims="%%AIN ('%REGEXE32BIT%QUERY"HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools" /v InstallationFolder')DOSETWINSDKNETFXTOOLS=%%B

‎src/fsharp/FSharp.Build/FSharpEmbedResourceText.fs‎

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,21 @@ open Printf
341341

342342
letgenerateResxAndSource(filename:string)=
343343
try
344-
letprintMessage message= printfn"FSharpEmbedResourceText:%s" message
345-
letjustfilename= 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-
letoutFilename= Path.Combine(_outputPath, justfilename+".fs")
349-
letoutXmlFilename= Path.Combine(_outputPath, justfilename+".resx")
344+
letprintMessage message= printfn"FSharpEmbedResourceText:%s" message
345+
letjustfilename= 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+
letoutFilename= Path.Combine(_outputPath, justfilename+".fs")
349+
letoutXmlFilename= 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
letlines= File.ReadAllLines(filename)
@@ -472,27 +481,28 @@ open Printf
472481
with get()=_hostObject
473482
andset(value)=_hostObject<- value
474483
memberthis.Execute()=
475-
letsourceItem(source:string)(originalItem:string)=
476-
letitem= TaskItem(source)
477-
item.SetMetadata("AutoGen","true")
478-
item.SetMetadata("DesignTime","true")
479-
item.SetMetadata("DependentUpon", originalItem)
480-
item:> ITaskItem
481-
letresxItem(resx:string)=
482-
letitem= TaskItem(resx)
483-
item.SetMetadata("ManifestResourceName", Path.GetFileNameWithoutExtension(resx))
484-
item:> ITaskItem
485-
letgeneratedFiles,generatedResult=
484+
485+
letgeneratedFiles=
486486
this.EmbeddedText
487-
|> Array.fold(fun(resultList,aggregateResult)item->
488-
match generateResxAndSource item.ItemSpecwith
489-
| Some(source, resx)->(((source, resx):: resultList), aggregateResult)
490-
| None->(resultList,false)
491-
)([],true)
487+
|> Array.choose(fun item-> generateResxAndSource item.ItemSpec)
488+
492489
letgeneratedSource,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 generatedFilesdo
491+
letsourceItem=
492+
letitem= TaskItem(source)
493+
item.SetMetadata("AutoGen","true")
494+
item.SetMetadata("DesignTime","true")
495+
item.SetMetadata("DependentUpon", resx)
496+
item:> ITaskItem
497+
letresxItem=
498+
letitem= TaskItem(resx)
499+
item.SetMetadata("ManifestResourceName", Path.GetFileNameWithoutExtension(resx))
500+
item:> ITaskItem
501+
yield(sourceItem, resxItem)|]
502+
|> Array.unzip
503+
504+
letgeneratedResult=(generatedFiles.Length= this.EmbeddedText.Length)
505+
506+
_generatedSource<- generatedSource
507+
_generatedResx<- generatedResx
498508
generatedResult

‎src/fsharp/FSharp.Build/Fsc.fs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
158158
let mutablesubsystemVersion:string=null
159159
let mutabletailcalls:bool=true
160160
let mutabletargetProfile:string=null
161-
let mutabletargetType:string=null
161+
let mutabletargetType:string=null
162162
let mutabletoolExe:string="fsc.exe"
163163
let mutabletoolPath:string=
164164
letlocationOfThisDll=
@@ -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 disabledWarningswith
283283
|null->()
@@ -418,7 +418,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
418418
// --noframework
419419
memberfsc.NoFramework
420420
with get()= noFramework
421-
andset(b)= noFramework<- b
421+
andset(b)= noFramework<- b
422422

423423
// --optimize
424424
memberfsc.Optimize
@@ -543,7 +543,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
543543
memberfsc.Win32ManifestFile
544544
with get()= win32manifest
545545
andset(m)= win32manifest<- m
546-
546+
547547
// For specifying the warning level (0-4)
548548
memberfsc.WarningLevel
549549
with get()= warningLevel
@@ -552,7 +552,7 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
552552
memberfsc.WarningsAsErrors
553553
with get()= warningsAsErrors
554554
andset(s)= warningsAsErrors<- s
555-
555+
556556
memberfsc.VisualStudioStyleErrors
557557
with get()= vserrors
558558
andset(p)= vserrors<- p
@@ -581,6 +581,9 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
581581
overridefsc.GenerateFullPathToTool()=
582582
if toolPath=""then raise(new System.InvalidOperationException(FSBuild.SR.toolpathUnknown()))
583583
System.IO.Path.Combine(toolPath, fsc.ToolExe)
584+
overridefsc.LogToolCommand(message:string)=
585+
fsc.Log.LogMessageFromText(message, MessageImportance.Normal)|>ignore
586+
584587
memberinternalfsc.InternalGenerateFullPathToTool()= fsc.GenerateFullPathToTool()// expose for unit testing
585588
memberinternalfsc.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‎

Lines changed: 4 additions & 0 deletions
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‎

Lines changed: 96 additions & 0 deletions
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+
letinput=
619+
"""
620+
open System
621+
622+
let _ =
623+
match ConsoleKey.Tab with
624+
| ConsoleKey.OemClear -> ConsoleKey.A
625+
| _ -> ConsoleKey.B
626+
"""
627+
628+
letfile="/home/user/Test.fsx"
629+
let_,typeCheckResults= parseAndCheckScript(file, input)
630+
typeCheckResults.GetAllUsesOfAllSymbolsInFile()
631+
|> Async.RunSynchronously
632+
|> Array.map(fun su->
633+
letr= 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+
letinput=
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+
letfile="/home/user/Test.fsx"
673+
let_,typeCheckResults= parseAndCheckScript(file, input)
674+
typeCheckResults.GetAllUsesOfAllSymbolsInFile()
675+
|> Async.RunSynchronously
676+
|> Array.map(fun su->
677+
letr= 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‎

Lines changed: 36 additions & 35 deletions
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-
privateboolLogAtImportance(MessageImportanceimportance)
560-
{
561-
// If importance is too low for current settings, ignore the event
562-
boollogIt=false;
563-
564-
this.SetVerbosity();
565-
566-
switch(this.Verbosity)
567-
{
568-
caseLoggerVerbosity.Quiet:
569-
logIt=false;
570-
break;
571-
caseLoggerVerbosity.Minimal:
572-
logIt=(importance==MessageImportance.High);
573-
break;
574-
caseLoggerVerbosity.Normal:
575-
// Falling through...
576-
caseLoggerVerbosity.Detailed:
577-
logIt=(importance!=MessageImportance.Low);
578-
break;
579-
caseLoggerVerbosity.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-
returnlogIt;
588-
}
559+
privateboolLogAtImportance(MessageImportanceimportance)
560+
{
561+
// If importance is too low for current settings, ignore the event
562+
boollogIt=false;
563+
564+
this.SetVerbosity();
565+
566+
switch(this.Verbosity)
567+
{
568+
caseLoggerVerbosity.Quiet:
569+
logIt=false;
570+
break;
571+
caseLoggerVerbosity.Minimal:
572+
logIt=(importance==MessageImportance.High);
573+
break;
574+
caseLoggerVerbosity.Normal:
575+
logIt=(importance==MessageImportance.Normal)||(importance==MessageImportance.High);
576+
break;
577+
caseLoggerVerbosity.Detailed:
578+
logIt=(importance==MessageImportance.Low)||(importance==MessageImportance.Normal)||(importance==MessageImportance.High);
579+
break;
580+
caseLoggerVerbosity.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+
returnlogIt;
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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<PropertyGroup>
4343
<Win32Resource>$(IntermediateOutputPath)\ProjectResources.rc.res</Win32Resource>
4444
</PropertyGroup>
45-
<TargetName="BeforeBuild">
45+
<TargetName="BeforeBuild"Condition="!Exists('$(IntermediateOutputPath)$(RCResourceFile).res')">
4646
<ExecCommand="&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
<ExecCommand="&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
<ExecCommand="&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)

[8]ページ先頭

©2009-2025 Movatter.jp