public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, IconAndManifestValue))
            {
                _temporaryPropertyStorage.AddOrUpdatePropertyValue(ResourceSpecificationKindProperty, IconAndManifestValue);

                await defaultProperties.SaveValueIfCurrentlySetAsync(Win32ResourceMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(Win32ResourceMSBuildProperty);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(ApplicationIconMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions);
            }
            else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, ResourceFileValue))
            {
                _temporaryPropertyStorage.AddOrUpdatePropertyValue(ResourceSpecificationKindProperty, ResourceFileValue);

                await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationIconMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(ApplicationIconMSBuildProperty);

                await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(Win32ResourceMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions);
            }

            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the application manifest kind property
        /// </summary>
        public override async Task <string?> OnSetPropertyValueAsync(
            string propertyName,
            string?unevaluatedPropertyValue,
            IProjectProperties defaultProperties,
            IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, DefaultManifestValue))
            {
                await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty);

                await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty);
            }
            else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, NoManifestValue))
            {
                await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty);

                await defaultProperties.SetPropertyValueAsync(NoManifestMSBuildProperty, "true");
            }
            else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, CustomManifestValue))
            {
                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty);
            }

            // We don't want to store a value for this so return null.
            return(null);
        }
        public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, ExpressionValue))
            {
                _temporaryPropertyStorage.AddOrUpdatePropertyValue(PackageLicenseKindProperty, ExpressionValue);

                await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseFileMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(PackageLicenseFileMSBuildProperty);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageLicenseExpressionMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageRequireLicenseAcceptanceMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions);
            }
            else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, FileValue))
            {
                _temporaryPropertyStorage.AddOrUpdatePropertyValue(PackageLicenseKindProperty, FileValue);

                await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseExpressionMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(PackageLicenseExpressionMSBuildProperty);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageLicenseFileMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageRequireLicenseAcceptanceMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions);
            }
            else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, NoneValue))
            {
                _temporaryPropertyStorage.AddOrUpdatePropertyValue(PackageLicenseKindProperty, NoneValue);

                await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseFileMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseExpressionMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.SaveValueIfCurrentlySetAsync(PackageRequireLicenseAcceptanceMSBuildProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(PackageLicenseFileMSBuildProperty);

                await defaultProperties.DeletePropertyAsync(PackageLicenseExpressionMSBuildProperty);

                await defaultProperties.DeletePropertyAsync(PackageRequireLicenseAcceptanceMSBuildProperty);
            }

            return(null);
        }
Ejemplo n.º 4
0
        public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, "true"))
            {
                // When setting this to "true", remove WarningsAsErrors
                await defaultProperties.SaveValueIfCurrentlySetAsync(WarningsAsErrorsProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(WarningsAsErrorsProperty, dimensionalConditions);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(WarningsNotAsErrorsProperty, _temporaryPropertyStorage);
            }
            else
            {
                // When settings this to "false", remove WarningsNotAsErrors
                await defaultProperties.SaveValueIfCurrentlySetAsync(WarningsNotAsErrorsProperty, _temporaryPropertyStorage);

                await defaultProperties.DeletePropertyAsync(WarningsNotAsErrorsProperty, dimensionalConditions);

                await defaultProperties.RestoreValueIfNotCurrentlySetAsync(WarningsAsErrorsProperty, _temporaryPropertyStorage);
            }

            return(await base.OnSetPropertyValueAsync(propertyName, unevaluatedPropertyValue, defaultProperties, dimensionalConditions));
        }
Ejemplo n.º 5
0
        public async Task WhenThePropertyIsSetInTheProject_TheValueIsSavedInTemporaryStorage()
        {
            IProjectProperties projectProperties = IProjectPropertiesFactory.CreateWithPropertiesAndValues(
                propertyNameAndValues: new Dictionary <string, string?>()
            {
                { "MyProperty", "Alpha" }
            },
                inheritedPropertyNames: new());

            Dictionary <string, string> storedValues             = new();
            ITemporaryPropertyStorage   temporaryPropertyStorage = ITemporaryPropertyStorageFactory.Create(values: storedValues);

            await projectProperties.SaveValueIfCurrentlySetAsync("MyProperty", temporaryPropertyStorage);

            Assert.Contains(new KeyValuePair <string, string>("MyProperty", "Alpha"), storedValues);
        }
Ejemplo n.º 6
0
        public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            if (bool.TryParse(unevaluatedPropertyValue, out bool value))
            {
                if (!value)
                {
                    await defaultProperties.SaveValueIfCurrentlySetAsync(DocumentationFileMSBuildProperty, _temporaryPropertyStorage);

                    await defaultProperties.DeletePropertyAsync(DocumentationFileMSBuildProperty);
                }
                else
                {
                    await defaultProperties.RestoreValueIfNotCurrentlySetAsync(DocumentationFileMSBuildProperty, _temporaryPropertyStorage);
                }
            }

            return(null);
        }
        public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            if (!bool.TryParse(unevaluatedPropertyValue, out bool value))
            {
                return(null);
            }

            // When true, remove WarningsAsErrors. Otherwise, remove WarningsNotAsErrors.
            string removePropertyName  = value ? WarningsAsErrorsProperty : WarningsNotAsErrorsProperty;
            string restorePropertyName = value ? WarningsNotAsErrorsProperty : WarningsAsErrorsProperty;

            await defaultProperties.SaveValueIfCurrentlySetAsync(removePropertyName, _temporaryPropertyStorage);

            await defaultProperties.DeletePropertyAsync(removePropertyName, dimensionalConditions);

            await defaultProperties.RestoreValueIfNotCurrentlySetAsync(restorePropertyName, _temporaryPropertyStorage, dimensionalConditions);

            return(unevaluatedPropertyValue);
        }