/// <summary> /// Given the set of parameters that are set to the factory, and the set of parameters coming from the task invocation that we're searching for /// a matching record to, determine whether the parameters match this record. /// </summary> private static bool TaskIdentityParametersMatchFactory(IDictionary <string, string> factoryIdentityParameters, IDictionary <string, string> taskIdentityParameters) { if (taskIdentityParameters == null || taskIdentityParameters.Count == 0 || factoryIdentityParameters == null || factoryIdentityParameters.Count == 0) { // either the task or the using task doesn't care about anything, in which case we match by default. return(true); } string taskRuntime = null; string taskArchitecture = null; string usingTaskRuntime = null; string usingTaskArchitecture = null; taskIdentityParameters.TryGetValue(XMakeAttributes.runtime, out taskRuntime); factoryIdentityParameters.TryGetValue(XMakeAttributes.runtime, out usingTaskRuntime); if (XMakeAttributes.RuntimeValuesMatch(taskRuntime, usingTaskRuntime)) { taskIdentityParameters.TryGetValue(XMakeAttributes.architecture, out taskArchitecture); factoryIdentityParameters.TryGetValue(XMakeAttributes.architecture, out usingTaskArchitecture); if (XMakeAttributes.ArchitectureValuesMatch(taskArchitecture, usingTaskArchitecture)) { // both match return(true); } } // one or more does not match, so we don't match. return(false); }
public void TestRuntimeValuesMatch() { Assert.IsTrue(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.any, XMakeAttributes.MSBuildRuntimeValues.currentRuntime)); Assert.IsTrue(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.any, XMakeAttributes.MSBuildRuntimeValues.clr4)); Assert.IsTrue(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.clr2, XMakeAttributes.MSBuildRuntimeValues.any)); Assert.IsTrue(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.currentRuntime, XMakeAttributes.MSBuildRuntimeValues.clr4)); Assert.IsFalse(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.currentRuntime, XMakeAttributes.MSBuildRuntimeValues.clr2)); Assert.IsFalse(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.clr4, XMakeAttributes.MSBuildRuntimeValues.clr2)); }
public void TestRuntimeValuesMatch() { Assert.True(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.any, XMakeAttributes.MSBuildRuntimeValues.currentRuntime)); Assert.True(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.any, XMakeAttributes.MSBuildRuntimeValues.net)); Assert.True(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.any, XMakeAttributes.MSBuildRuntimeValues.clr4)); Assert.True(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.clr2, XMakeAttributes.MSBuildRuntimeValues.any)); #if NET5_0_OR_GREATER Assert.True(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.currentRuntime, XMakeAttributes.MSBuildRuntimeValues.net)); #else Assert.True(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.currentRuntime, XMakeAttributes.MSBuildRuntimeValues.clr4)); #endif // Never true Assert.False(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.currentRuntime, XMakeAttributes.MSBuildRuntimeValues.clr2)); Assert.False(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.clr4, XMakeAttributes.MSBuildRuntimeValues.clr2)); Assert.False(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.clr4, XMakeAttributes.MSBuildRuntimeValues.net)); Assert.False(XMakeAttributes.RuntimeValuesMatch(XMakeAttributes.MSBuildRuntimeValues.clr2, XMakeAttributes.MSBuildRuntimeValues.net)); }