/// <summary> /// Returns true if the given project configurations are equal ignoring the "TargetFramework" dimension. /// </summary> internal static bool EqualIgnoringTargetFramework(this ProjectConfiguration projectConfiguration1, ProjectConfiguration projectConfiguration2) { Requires.NotNull(projectConfiguration1, nameof(projectConfiguration1)); Requires.NotNull(projectConfiguration2, nameof(projectConfiguration2)); if (projectConfiguration1.Dimensions.Count != projectConfiguration2.Dimensions.Count) { return(false); } if (!projectConfiguration1.IsCrossTargeting() || !projectConfiguration2.IsCrossTargeting()) { return(projectConfiguration1.Equals(projectConfiguration2)); } foreach ((string dimensionName, string dimensionValue) in projectConfiguration1.Dimensions) { // Ignore the TargetFramework. if (StringComparers.ConfigurationDimensionNames.Equals(dimensionName, ConfigurationGeneral.TargetFrameworkProperty)) { continue; } // Dimension values must be compared in a case-sensitive manner. if (!projectConfiguration2.Dimensions.TryGetValue(dimensionName, out string activeValue) || !string.Equals(dimensionValue, activeValue, StringComparisons.ConfigurationDimensionNames)) { return(false); } } return(true); }
/// <summary> /// Returns true if the given project configurations are equal ignoring the "TargetFramework" dimension. /// </summary> internal static bool EqualIgnoringTargetFramework(this ProjectConfiguration projectConfiguration1, ProjectConfiguration projectConfiguration2) { Requires.NotNull(projectConfiguration1, nameof(projectConfiguration1)); Requires.NotNull(projectConfiguration2, nameof(projectConfiguration2)); if (projectConfiguration1.Dimensions.Count != projectConfiguration2.Dimensions.Count) { return(false); } if (!projectConfiguration1.IsCrossTargeting() || !projectConfiguration2.IsCrossTargeting()) { return(projectConfiguration1.Equals(projectConfiguration2)); } foreach (var dimensionKvp in projectConfiguration1.Dimensions) { var dimensionName = dimensionKvp.Key; var dimensionValue = dimensionKvp.Value; // Ignore the TargetFramework. if (string.Equals(dimensionName, TargetFrameworkProjectConfigurationDimensionProvider.TargetFrameworkPropertyName, StringComparison.OrdinalIgnoreCase)) { continue; } // Dimension values must be compared in a case-sensitive manner. string activeValue; if (!projectConfiguration2.Dimensions.TryGetValue(dimensionName, out activeValue) || !string.Equals(dimensionValue, activeValue, StringComparison.Ordinal)) { return(false); } } return(true); }