Пример #1
0
        protected override void ExecuteCore()
        {
            StronglyTypedInputs inputs = GetInputs();

            string cacheKey = inputs.CacheKey();

            ResolvedAssetsCacheEntry results;

            if (s_allowCacheLookup &&
                BuildEngine4?.GetRegisteredTaskObject(
                    cacheKey,
                    RegisteredTaskObjectLifetime.AppDomain /* really "until process exit" */)
                is ResolvedAssetsCacheEntry cacheEntry)
            {
                // NOTE: It's conceivably possible that the user modified the targeting
                //       packs between builds. Since that is extremely rare and the standard
                //       user scenario reads the targeting pack contents over and over without
                //       modification, we're electing not to check for file modification and
                //       returning any cached results that we have.

                results = cacheEntry;
            }
            else
            {
                results = Resolve(inputs, BuildEngine4);

                if (s_allowCacheLookup)
                {
                    BuildEngine4?.RegisterTaskObject(cacheKey, results, RegisteredTaskObjectLifetime.AppDomain, allowEarlyCollection: true);
                }
            }

            foreach (var error in results.Errors)
            {
                Log.LogError(error);
            }

            ReferencesToAdd                  = results.ReferencesToAdd;
            AnalyzersToAdd                   = results.AnalyzersToAdd;
            PlatformManifests                = results.PlatformManifests;
            PackageConflictOverrides         = results.PackageConflictOverrides;
            PackageConflictPreferredPackages = results.PackageConflictPreferredPackages;
            UsedRuntimeFrameworks            = results.UsedRuntimeFrameworks;
        }
Пример #2
0
            static IEnumerable <(string LastFieldChanged, StronglyTypedInputs Inputs)> Permutations(StronglyTypedInputs input)
            {
                var properties = typeof(StronglyTypedInputs).GetProperties(BindingFlags.Public | BindingFlags.Instance);

                foreach (var property in properties)
                {
                    if (property.PropertyType == typeof(FrameworkReference[]))
                    {
                        var currentValue = (FrameworkReference[])property.GetValue(input);

                        foreach (var subfield in typeof(FrameworkReference).GetProperties())
                        {
                            if (subfield.PropertyType == typeof(string))
                            {
                                subfield.SetValue(currentValue[0], $"{subfield.Name}_changed");
                                yield return($"{property.Name}.{subfield.Name}", input);

                                continue;
                            }

                            Assert.True(false, $"update test to understand fields of type {subfield.PropertyType} in {nameof(FrameworkReference)}");
                        }
                    }
                    else if (property.PropertyType == typeof(TargetingPack[]))
                    {
                        var currentValue = (TargetingPack[])property.GetValue(input);

                        foreach (var subproperty in typeof(TargetingPack).GetProperties())
                        {
                            if (subproperty.PropertyType == typeof(string))
                            {
                                subproperty.SetValue(currentValue[0], $"{subproperty.Name}_changed");
                                yield return($"{property.Name}.{subproperty.Name}", input);

                                continue;
                            }

                            Assert.True(false, $"update test to understand fields of type {subproperty.PropertyType} in {nameof(TargetingPack)}");
                        }
                    }
                    else if (property.PropertyType == typeof(RuntimeFramework[]))
                    {
                        var currentValue = (RuntimeFramework[])property.GetValue(input);

                        foreach (var subproperty in typeof(RuntimeFramework).GetProperties())
                        {
                            if (subproperty.PropertyType == typeof(string))
                            {
                                subproperty.SetValue(currentValue[0], $"{subproperty.Name}_changed");
                                yield return($"{property.Name}.{subproperty.Name}", input);

                                continue;
                            }

                            if (subproperty.PropertyType == typeof(ITaskItem))
                            {
                                // Used to store original items but not cache-relevant
                                continue;
                            }

                            Assert.True(false, $"update test to understand fields of type {subproperty.PropertyType} in {nameof(RuntimeFramework)}");
                        }
                    }
                    else if (property.PropertyType == typeof(string))
                    {
                        property.SetValue(input, $"{property.Name}_changed");
                        yield return(property.Name, input);
                    }
                    else if (property.PropertyType == typeof(bool))
                    {
                        property.SetValue(input, !(bool)property.GetValue(input));
                        yield return(property.Name, input);
                    }
                    else
                    {
                        Assert.True(false, $"Unknown type {property.PropertyType} for field {property.Name}");
                    }
                }
            }