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

Commitf677819

Browse files
committed
fix app.config up-to-date status
1 parentbc41935 commitf677819

File tree

2 files changed

+112
-9
lines changed

2 files changed

+112
-9
lines changed

‎vsintegration/src/unittests/Tests.ProjectSystem.UpToDate.fs‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,55 @@ type UpToDate() =
326326

327327
Assert.IsFalse(config.IsFastUpToDateCheckEnabled())
328328
))
329+
330+
[<TestFixture>]
331+
type``UpToDate PreserveNewest``()=
332+
333+
[<Test>]
334+
memberpublicthis.IsUpToDatePreserveNewest()=
335+
336+
lettest(input,inputTimestamp)(output,outputTimestamp)=
337+
letlogs= ref[]
338+
letoutputPanel= VsMocks.vsOutputWindowPane(logs)
339+
letlogger= OutputWindowLogger.CreateUpToDateCheckLogger(outputPanel)
340+
341+
lettryTimestamp(path:string)(_l:OutputWindowLogger)=
342+
lettoN=function Some d-> Nullable<_>(d)| None-> Nullable<_>()
343+
match pathwith
344+
| xwhen x= input-> toN inputTimestamp
345+
| xwhen x= output-> toN outputTimestamp
346+
|_-> failwithf"unexpected%s" path
347+
348+
letu= ProjectConfig.IsUpToDatePreserveNewest(logger,(Func<_,_,_>(tryTimestamp)), input, output)
349+
u,!logs
350+
351+
letnow= System.DateTime.Now
352+
letbefore= now.AddHours(-1.0)
353+
354+
let``no input->not up-to-date and log``=
355+
letu,logs= test("readme.md", None)("leggimi.md", None)
356+
Assert.IsFalse(u)
357+
logs
358+
|> List.exists(fun s-> s.Contains("readme.md")&& s.Contains("can't find expected input"))
359+
|> Assert.IsTrue
360+
361+
let``no output->not up-to-date and log``=
362+
letu,logs= test("from.txt", Some now)("to.txt", None)
363+
Assert.IsFalse(u)
364+
logs
365+
|> List.exists(fun s-> s.Contains("to.txt")&& s.Contains("can't find expected output"))
366+
|> Assert.IsTrue
367+
368+
let``a newer version of output file is ok``=
369+
letu,logs= test("before.doc", Some before)("after.doc", Some now)
370+
Assert.True(u)
371+
logs|> AssertEqual[]
372+
373+
let``stale output file->not up-to-date and log``=
374+
letu,logs= test("logo.png", Some now)("animatedlogo.gif", Some before)
375+
Assert.IsFalse(u)
376+
logs
377+
|> List.exists(fun s-> s.Contains("animatedlogo.gif")&& s.Contains("stale"))
378+
|> Assert.IsTrue
379+
380+
()

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectConfig.cs‎

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ public virtual int QueryDebugTargets(uint grfLaunch, uint cTargets, VsDebugTarge
11971197
publicvirtualintOpenOutputGroup(stringszCanonicalName,outIVsOutputGroupppIVsOutputGroup)
11981198
{
11991199
ppIVsOutputGroup=null;
1200-
// Search through our list of groups to find the one they are lookingforgroupName
1200+
// Search through our list of groups to find the one they are lookingfor groupName
12011201
foreach(OutputGroupgroupinOutputGroups)
12021202
{
12031203
stringgroupName;
@@ -1458,7 +1458,7 @@ private static bool IsPossibleOutputGroup(string groupName)
14581458
returnnull;
14591459
}
14601460

1461-
internalboolGetUTDCheckInputs(refHashSet<string>inputs)
1461+
internalboolGetUTDCheckInputs(HashSet<string>inputs)
14621462
{
14631463
// the project file itself
14641464
inputs.Add(Utilities.CanonicalizeFileNameNoThrow(this.project.BuildProject.FullPath));
@@ -1527,8 +1527,10 @@ internal bool GetUTDCheckInputs(ref HashSet<string> inputs)
15271527
returntrue;
15281528
}
15291529

1530-
internalboolGetUTDCheckOutputs(refHashSet<string>outputs,HashSet<string>inputs)
1530+
internalvoidGetUTDCheckOutputs(HashSet<string>inputs,HashSet<string>outputs,outList<Tuple<string,string>>preserveNewestOutputs)
15311531
{
1532+
preserveNewestOutputs=newList<Tuple<string,string>>();
1533+
15321534
// Output groups give us the paths to the following outputs
15331535
// result EXE or DLL in "obj" dir
15341536
// PDB file in "obj" dir (if project is configured to create this)
@@ -1546,15 +1548,29 @@ internal bool GetUTDCheckOutputs(ref HashSet<string> outputs, HashSet<string> in
15461548
varoutputAssembly=this.project.GetOutputAssembly(this.ConfigCanonicalName);
15471549
outputs.Add(Utilities.CanonicalizeFileNameNoThrow(outputAssembly));
15481550

1551+
boolisExe=outputAssembly.EndsWith(".exe",StringComparison.OrdinalIgnoreCase);
1552+
15491553
// final PDB path
15501554
if(this.DebugSymbols&&
1551-
(outputAssembly.EndsWith(".exe",StringComparison.OrdinalIgnoreCase)||outputAssembly.EndsWith(".dll",StringComparison.OrdinalIgnoreCase)))
1555+
(isExe||outputAssembly.EndsWith(".dll",StringComparison.OrdinalIgnoreCase)))
15521556
{
15531557
varpdbPath=outputAssembly.Remove(outputAssembly.Length-4)+".pdb";
15541558
outputs.Add(Utilities.CanonicalizeFileNameNoThrow(pdbPath));
15551559
}
15561560

1557-
returntrue;
1561+
if(isExe)
1562+
{
1563+
varappConfig=inputs.FirstOrDefault(x=>String.Compare(Path.GetFileName(x),"app.config",StringComparison.OrdinalIgnoreCase)==0);
1564+
if(appConfig!=null)
1565+
{
1566+
// the app.config is not removed from the inputs to maintain
1567+
// the same behavior of a C# project:
1568+
// When a app.config is changed, after the build, the project
1569+
// is not up-to-date until a rebuild
1570+
varexeConfig=Utilities.CanonicalizeFileNameNoThrow(outputAssembly+".config");
1571+
preserveNewestOutputs.Add(Tuple.Create(appConfig,exeConfig));
1572+
}
1573+
}
15581574
}
15591575

15601576
// there is a well-known property users can specify that signals for UTD check to be disabled
@@ -1584,12 +1600,12 @@ internal bool IsUpToDate(OutputWindowLogger logger, bool testing)
15841600
}
15851601

15861602
varinputs=newHashSet<string>(StringComparer.OrdinalIgnoreCase);
1587-
if(!GetUTDCheckInputs(refinputs))
1603+
if(!GetUTDCheckInputs(inputs))
15881604
returnfalse;
15891605

15901606
varoutputs=newHashSet<string>(StringComparer.OrdinalIgnoreCase);
1591-
if(!GetUTDCheckOutputs(refoutputs,inputs))
1592-
returnfalse;
1607+
List<Tuple<string,string>>preserveNewestOutputs;
1608+
GetUTDCheckOutputs(inputs,outputs,outpreserveNewestOutputs);
15931609

15941610
// determine the oldest output timestamp
15951611
DateTimestalestOutputTime=DateTime.MaxValue.ToUniversalTime();
@@ -1625,13 +1641,48 @@ internal bool IsUpToDate(OutputWindowLogger logger, bool testing)
16251641
freshestInputTime=timeStamp.Value;
16261642
}
16271643

1644+
// check 1-1 Preserve Newest mappings
1645+
foreach(varkvinpreserveNewestOutputs)
1646+
{
1647+
if(!IsUpToDatePreserveNewest(logger,TryGetLastWriteTimeUtc,kv.Item1,kv.Item2))
1648+
returnfalse;
1649+
}
1650+
16281651
logger.WriteLine("Freshest input: {0}",freshestInputTime.ToLocalTime());
16291652
logger.WriteLine("Stalest output: {0}",stalestOutputTime.ToLocalTime());
16301653
logger.WriteLine("Up to date: {0}",freshestInputTime<=stalestOutputTime);
16311654

1632-
// if all outputs are younger than allinuts, we are up to date
1655+
// if all outputs are younger than allinputs, we are up to date
16331656
returnfreshestInputTime<=stalestOutputTime;
16341657
}
1658+
1659+
publicstaticboolIsUpToDatePreserveNewest(OutputWindowLoggerlogger,Func<string,OutputWindowLogger,DateTime?>tryGetLastWriteTimeUtc,stringinput,stringoutput)
1660+
{
1661+
varinputTime=tryGetLastWriteTimeUtc(input,logger);
1662+
if(!inputTime.HasValue)
1663+
{
1664+
logger.WriteLine("Declaring project NOT up to date, can't find expected input {0}",input);
1665+
returnfalse;
1666+
}
1667+
1668+
varoutputTime=tryGetLastWriteTimeUtc(output,logger);
1669+
if(!outputTime.HasValue)
1670+
{
1671+
logger.WriteLine("Declaring project NOT up to date, can't find expected output {0}",output);
1672+
returnfalse;
1673+
}
1674+
1675+
varinputTimeValue=inputTime.Value;
1676+
varoutputTimeValue=outputTime.Value;
1677+
1678+
if(outputTimeValue<inputTimeValue)
1679+
{
1680+
logger.WriteLine("Declaring project NOT up to date, ouput {0} is stale",output);
1681+
returnfalse;
1682+
}
1683+
1684+
returntrue;
1685+
}
16351686
}
16361687

16371688
internalclassClassLibraryCannotBeStartedDirectlyException:COMException

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp