Skip to content

Commit

Permalink
Merge pull request #78 from microsoft/users/richsta/distilonsave
Browse files Browse the repository at this point in the history
Move distill rules from reader to writer.
richardstanton authored Nov 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents f5c1f30 + 1ea8c46 commit aa1b8e3
Showing 7 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.SolutionPersistence.Model;
/// <summary>
/// Helper to process configuration rules.
/// </summary>
internal readonly struct ConfigurationRuleFollower(IReadOnlyList<ConfigurationRule>? configurationRules)
internal readonly ref struct ConfigurationRuleFollower(IReadOnlyList<ConfigurationRule>? configurationRules)
{
private readonly IReadOnlyList<ConfigurationRule>? configurationRules = configurationRules;

Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ internal sealed partial class SolutionConfigurationMap
/// </summary>
/// <param name="projectMappings">The mappings to update.</param>
/// <param name="scopedRules">The rules to run, scoped to their effect.</param>
private void ApplyRules(in SolutionToProjectMappings projectMappings, in ScopedRules scopedRules)
private void ApplyRules(in SolutionToProjectMappings projectMappings, scoped in ScopedRules scopedRules)
{
int iBuildTypeBegin = scopedRules.BuildTypeIndex == ScopedRules.All ? 0 : scopedRules.BuildTypeIndex;
int iBuildTypeEnd = scopedRules.BuildTypeIndex == ScopedRules.All ? this.BuildTypesCount : scopedRules.BuildTypeIndex + 1;
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ namespace Microsoft.VisualStudio.SolutionPersistence.Model;
internal sealed partial class SolutionConfigurationMap
{
private readonly SolutionModel solutionModel;
private readonly Dictionary<string, int> buildTypesIndex = [];
private readonly Dictionary<string, int> platformsIndex = [];
private readonly Dictionary<string, int> buildTypesIndex;
private readonly Dictionary<string, int> platformsIndex;

private readonly Dictionary<SolutionProjectModel, SolutionToProjectMappings> perProjectCurrent = [];

@@ -19,11 +19,13 @@ internal sealed partial class SolutionConfigurationMap
internal SolutionConfigurationMap(SolutionModel solutionModel)
{
this.solutionModel = solutionModel;
this.buildTypesIndex = new Dictionary<string, int>(solutionModel.BuildTypes.Count);
for (int i = 0; i < solutionModel.BuildTypes.Count; i++)
{
this.buildTypesIndex.Add(solutionModel.BuildTypes[i], i);
}

this.platformsIndex = new Dictionary<string, int>(solutionModel.Platforms.Count);
for (int i = 0; i < solutionModel.Platforms.Count; i++)
{
this.platformsIndex.Add(PlatformNames.Canonical(solutionModel.Platforms[i]), i);
Original file line number Diff line number Diff line change
@@ -265,8 +265,6 @@ static void SetProjectConfigurationPlatforms(SolutionModel solution, SolutionPro
{
ParseProjectConfigLine(solution, projectKey, projectValue);
}

solution.DistillProjectConfigurations();
}

// Applies a .SLN configuration line to the current project configuration.
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@ internal static async Task SaveAsync(
model.RemoveObsoleteProperties();
}

model.DistillProjectConfigurations();

// If this started as an XML document, merge the changes back into the original document.
SlnxFile root = modelExtension?.Root ?? CreateNewSlnFile(fullPath, xmlSerializerSettings, model.StringTable);

Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ static void CreateModifiedModel(SolutionModel solution)

SolutionProjectModel? project = solution.FindProject(Path.Join("other", "Project4.nativeproj"));
Assert.NotNull(project);
project.AddProjectConfigurationRule(new ConfigurationRule(BuildDimension.Platform, "*", "Z80", "Z80"));
project.AddProjectConfigurationRule(new ConfigurationRule(BuildDimension.Platform, "*", "Arm64", "Z80"));

SolutionProjectModel? project3 = solution.FindProject("Project3.csproj");
Assert.NotNull(project3);
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@
<BuildDependency Project="Project2.nativeproj" />
<BuildDependency Project="Project3.csproj" />
<BuildDependency Project="Project3.nativeproj" />
<Platform Solution="*|Z80" Project="Z80" />
<Platform Solution="*|Arm64" Project="Z80" />
</Project>
<Project Path="other/Project5.nativeproj" />
<Project Path="other/Project6.nativeproj" />

0 comments on commit aa1b8e3

Please sign in to comment.