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

Commit322d27f

Browse files
committed
Proper handling of VSUTDCF options in up-to-date check, and safer TryGetActiveConfigurationAndPlatform
- Use `IVsSolutionBuildManager5.FindActiveProjectCfgName` instead of `IVsSolutionBuildManager2.FindActiveProjectCfg` in `TryGetActiveConfigurationAndPlatform`, as it is not sensitive to sync context - Give proper consideration to the VSUTDCF options flags passed to QueryStartUpToDateCheckfixesdotnet#471closesdotnet#479
1 parent64c4ea6 commit322d27f

File tree

5 files changed

+74
-24
lines changed

5 files changed

+74
-24
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,58 @@ type UpToDate() =
327327
Assert.IsFalse(config.IsFastUpToDateCheckEnabled())
328328
))
329329

330+
[<Test>]
331+
memberpublicthis.UTDOptionsFlags()=
332+
this.MakeProjectAndDo(["file1.fs"],[],"",(fun project->
333+
letconfigNameDebugx86= ConfigCanonicalName("Debug","x86")
334+
letdebugConfigx86= project.ConfigProvider.GetProjectConfiguration(configNameDebugx86)
335+
letbuildableConfig=
336+
match debugConfigx86.get_BuildableProjectCfg()with
337+
|0, bc-> bc
338+
|_-> failwith"get_BuildableProjectCfg failed"
339+
340+
lettestFlag flag expected=
341+
letsupported= Array.zeroCreate<int>1
342+
letready= Array.zeroCreate<int>1
343+
buildableConfig.QueryStartUpToDateCheck(flag, supported, ready)|> ignore
344+
Assert.IsTrue(supported.[0]= expected)
345+
Assert.IsTrue(ready.[0]= expected)
346+
347+
[ VSConstants.VSUTDCF_DTEEONLY,1
348+
VSConstants.VSUTDCF_PACKAGE,0
349+
VSConstants.VSUTDCF_PRIVATE,1
350+
VSConstants.VSUTDCF_REBUILD,1]
351+
|> List.iter(fun(flag,expected)-> testFlag flag expected)
352+
))
353+
354+
[<Test>]
355+
memberpublicthis.UTDOptionsFlagsUTDDisabled()=
356+
this.MakeProjectAndDo(["file1.fs"],[],@"
357+
<PropertyGroup>
358+
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
359+
</PropertyGroup>
360+
",(fun project->
361+
letconfigNameDebugx86= ConfigCanonicalName("Debug","x86")
362+
letdebugConfigx86= project.ConfigProvider.GetProjectConfiguration(configNameDebugx86)
363+
letbuildableConfig=
364+
match debugConfigx86.get_BuildableProjectCfg()with
365+
|0, bc-> bc
366+
|_-> failwith"get_BuildableProjectCfg failed"
367+
368+
lettestFlag flag expected=
369+
letsupported= Array.zeroCreate<int>1
370+
letready= Array.zeroCreate<int>1
371+
buildableConfig.QueryStartUpToDateCheck(flag, supported, ready)|> ignore
372+
Assert.AreEqual(supported.[0], expected)
373+
Assert.AreEqual(ready.[0], expected)
374+
375+
[ VSConstants.VSUTDCF_DTEEONLY,1
376+
VSConstants.VSUTDCF_PACKAGE,0
377+
VSConstants.VSUTDCF_PRIVATE,0
378+
VSConstants.VSUTDCF_REBUILD,0]
379+
|> List.iter(fun(flag,expected)-> testFlag flag expected)
380+
))
381+
330382
[<TestFixture>]
331383
type``UpToDate PreserveNewest``()=
332384

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,8 @@ internal bool IsUpToDate(OutputWindowLogger logger, bool testing)
15911591
// in batch build it is possible that config is out of sync.
15921592
// in this case, don't assume we are up to date
15931593
ConfigCanonicalNameactiveConfig=default(ConfigCanonicalName);
1594-
if(!Utilities.TryGetActiveConfigurationAndPlatform(ServiceProvider.GlobalProvider,this.project,outactiveConfig)||
1594+
1595+
if(!Utilities.TryGetActiveConfigurationAndPlatform(ServiceProvider.GlobalProvider,this.project.ProjectIDGuid,outactiveConfig)||
15951596
activeConfig!=this.ConfigCanonicalName)
15961597
{
15971598
logger.WriteLine("Not up to date: active confic does not match project config. Active: {0} Project: {1}",activeConfig,this.ConfigCanonicalName);
@@ -1836,12 +1837,21 @@ public virtual int QueryStartUpToDateCheck(uint options, int[] supported, int[]
18361837
CCITracing.TraceCall();
18371838
config.PrepareBuild(false);
18381839

1839-
intutdSupported=config.IsFastUpToDateCheckEnabled()?1:0;
1840+
// criteria (same as C# project system):
1841+
// - Fast UTD never enabled for package operations
1842+
// - Fast UTD always enabled for DTEE operations
1843+
// - Otherwise fast UTD enabled as long as it's not explicitly disabled by the project
1844+
boolutdSupported=
1845+
((options&VSConstants.VSUTDCF_PACKAGE)==0)&&
1846+
(((options&VSConstants.VSUTDCF_DTEEONLY)!=0)||config.IsFastUpToDateCheckEnabled());
1847+
1848+
intutdSupportedFlag=utdSupported?1:0;
18401849

18411850
if(supported!=null&&supported.Length>0)
1842-
supported[0]=utdSupported;
1851+
supported[0]=utdSupportedFlag;
18431852
if(ready!=null&&ready.Length>0)
1844-
ready[0]=utdSupported;
1853+
ready[0]=utdSupportedFlag;
1854+
18451855
returnVSConstants.S_OK;
18461856
}
18471857

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,7 +4150,7 @@ internal virtual void SetConfiguration(ConfigCanonicalName configCanonicalName)
41504150
// REVIEW/TODO: shall we abandon accessing automation here and just look at MSBuild state?
41514151
EnvDTE.ProjectautomationObject=this.GetAutomationObject()asEnvDTE.Project;
41524152
ConfigCanonicalNamecurrentConfigName;
4153-
if(Utilities.TryGetActiveConfigurationAndPlatform(this.Site,InteropSafeIVsHierarchy,outcurrentConfigName))
4153+
if(Utilities.TryGetActiveConfigurationAndPlatform(this.Site,this.ProjectIDGuid,outcurrentConfigName))
41544154
{
41554155
if(currentConfigName==configCanonicalName)return;
41564156
}
@@ -4346,7 +4346,7 @@ internal virtual void OnHandleConfigurationRelatedGlobalProperties(object sender
43464346
}
43474347

43484348
ConfigCanonicalNameconfigCanonicalName;
4349-
if(!Utilities.TryGetActiveConfigurationAndPlatform(this.Site,InteropSafeIVsHierarchy,outconfigCanonicalName))
4349+
if(!Utilities.TryGetActiveConfigurationAndPlatform(this.Site,this.ProjectIDGuid,outconfigCanonicalName))
43504350
{
43514351
thrownewInvalidOperationException();
43524352
}

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -940,38 +940,26 @@ public static string CanonicalizeFileNameNoThrow(string anyFileName)
940940
/// <param name="configuration">The name of the active configuration.</param>
941941
/// <param name="platform">The name of the platform.</param>
942942
/// <returns>true if successfull.</returns>
943-
/*internal, but public for FSharp.Project.dll*/publicstaticboolTryGetActiveConfigurationAndPlatform(System.IServiceProviderserviceProvider,IVsHierarchyhierarchy,outConfigCanonicalNameconfigCanonicalName)
943+
/*internal, but public for FSharp.Project.dll*/publicstaticboolTryGetActiveConfigurationAndPlatform(System.IServiceProviderserviceProvider,GuidprojectId,outConfigCanonicalNameconfigCanonicalName)
944944
{
945945
if(serviceProvider==null)
946946
{
947947
thrownewArgumentNullException("serviceProvider");
948948
}
949949

950-
if(hierarchy==null)
951-
{
952-
thrownewArgumentNullException("hierarchy");
953-
}
954-
955-
956-
IVsSolutionBuildManager2solutionBuildManager=serviceProvider.GetService(typeof(SVsSolutionBuildManager))asIVsSolutionBuildManager2;
950+
IVsSolutionBuildManager5solutionBuildManager=serviceProvider.GetService(typeof(SVsSolutionBuildManager))asIVsSolutionBuildManager5;
957951

958952
if(solutionBuildManager==null)
959953
{
960954
configCanonicalName=newConfigCanonicalName();
961955
returnfalse;
962956
}
963957

964-
IVsProjectCfg[]activeConfigs=newIVsProjectCfg[1];
965-
ErrorHandler.ThrowOnFailure(solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero,IntPtr.Zero,hierarchy,activeConfigs));
966-
967-
IVsProjectCfgactiveCfg=activeConfigs[0];
968-
969-
// Can it be that the activeCfg is null?
970-
System.Diagnostics.Debug.Assert(activeCfg!=null,"Cannot find the active configuration");
971-
972958
stringcanonicalName;
973-
ErrorHandler.ThrowOnFailure(activeCfg.get_CanonicalName(outcanonicalName));
959+
ErrorHandler.ThrowOnFailure(solutionBuildManager.FindActiveProjectCfgName(projectId,outcanonicalName));
960+
974961
configCanonicalName=newConfigCanonicalName(canonicalName);
962+
975963
returntrue;
976964
}
977965

‎vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g.
21372137
if GetCaption(pHierProj)= GetCaption(projNode.InteropSafeIVsHierarchy)then
21382138
// This code matches what ProjectNode.SetConfiguration would do; that method cannot be called during a build, but at this
21392139
// current moment in time, it is 'safe' to do this update.
2140-
let_,currentConfigName= Utilities.TryGetActiveConfigurationAndPlatform(projNode.Site, projNode.InteropSafeIVsHierarchy)
2140+
let_,currentConfigName= Utilities.TryGetActiveConfigurationAndPlatform(projNode.Site, projNode.ProjectIDGuid)
21412141
MSBuildProject.SetGlobalProperty(projNode.BuildProject, ProjectFileConstants.Configuration, currentConfigName.ConfigName)
21422142
MSBuildProject.SetGlobalProperty(projNode.BuildProject, ProjectFileConstants.Platform, currentConfigName.MSBuildPlatform)
21432143
projNode.UpdateMSBuildState()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp