-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix solution parsing in dotnet test for Microsoft.Testing.Platform #51411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/10.0.2xx
Are you sure you want to change the base?
Conversation
| var msbuildArgs = MSBuildArgs.AnalyzeMSBuildArguments(buildOptions.MSBuildArgs, CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, CommonOptions.MSBuildTargetOption(), CommonOptions.VerbosityOption()); | ||
| if (string.IsNullOrEmpty(activeSolutionConfiguration)) | ||
| { | ||
| activeSolutionConfiguration = solutionFile.GetDefaultConfigurationName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rainersigwald @baronfel Can this be null or empty under any scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure, would need to reach out to the VS Solution team for clarification on specific behaviors.
| activeSolutionPlatform = solutionFile.GetDefaultPlatformName(); | ||
| } | ||
|
|
||
| var solutionConfiguration = solutionFile.SolutionConfigurations.FirstOrDefault(c => c.ConfigurationName == activeSolutionConfiguration && c.PlatformName == activeSolutionPlatform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rainersigwald @baronfel Is this the right way to get the solution configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you may need to handle the case where the solution configuration accepts any platform? but am not certain, again a question for the VS Solution team about required solution behaviors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Platform and configuration are case insensitive, so if they are coming from the user's command line, these checks should ignore case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A valid solution file will always have at least one solution configuration and solution platform, it should be safe to not continue if this isn't true.
| var solutionConfiguration = solutionFile.SolutionConfigurations.FirstOrDefault(c => c.ConfigurationName == activeSolutionConfiguration && c.PlatformName == activeSolutionPlatform) | ||
| ?? throw new InvalidOperationException($"The solution configuration '{activeSolutionConfiguration}|{activeSolutionPlatform}' is invalid."); | ||
|
|
||
| // TODO: What to do if the given key doesn't exist in the ProjectConfigurations? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rainersigwald @baronfel Few lines below, I'm filtering projects only where the project configurations contains the requested solution configuration. Should that be an error instead if the solution configuration isn't found in the dictionary? or is it a valid scenario? And if valid scenario, is skipping the project the right behavior?
| using var collection = new ProjectCollection(globalProperties: CommonRunHelpers.GetGlobalPropertiesFromArgs(msbuildArgs), logger is null ? null : [logger], toolsetDefinitionLocations: ToolsetDefinitionLocations.Default); | ||
| var evaluationContext = EvaluationContext.Create(EvaluationContext.SharingPolicy.Shared); | ||
| IEnumerable<ParallelizableTestModuleGroupWithSequentialInnerModules> projects = SolutionAndProjectUtility.GetProjectProperties(projectFilePath, collection, evaluationContext, buildOptions); | ||
| IEnumerable<ParallelizableTestModuleGroupWithSequentialInnerModules> projects = SolutionAndProjectUtility.GetProjectProperties(projectFilePath, collection, evaluationContext, buildOptions, configuration: null, platform: null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this code path we are dealing with a single project.
| globalProperties.TryGetValue("Configuration", out var activeSolutionConfiguration); | ||
| globalProperties.TryGetValue("Platform", out var activeSolutionPlatform); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Configuration/Platform here are "solution configuration". This maps then to "project configuration" on the individual project files.
Should we clear out those values from the dictionary at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good line of thinking, I think you may be right. To do it right you'd use this to find the solutionconfiguration, and then use the solutionconfiguration to find per-project configuration/platform/etc arguments as we talked about today.
| .Where(p => ProjectShouldBuild(solutionFile, p.RelativePath) && p.ProjectConfigurations.ContainsKey(solutionConfiguration.FullName)) | ||
| .Select(p => (p.ProjectConfigurations[solutionConfiguration.FullName], p.AbsolutePath)) | ||
| .Where(p => p.Item1.IncludeInBuild) | ||
| .Select(p => (p.AbsolutePath, p.Item1.ConfigurationName, p.Item1.PlatformName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rainersigwald @baronfel Can ConfigurationName or PlatformName here be null or empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure, to me these are all questions about solution behavior - and such the VS Solution team needs to eb brought in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid projects require a configuration name, but platform is options. For example, reporting projects and setup projects don't have platforms. Also, there are many invalid solution files out there were configurations may be missing from the file. What to do in those cases is up to the tool, but it should probably be ignored, but not skip other valid projects.
|
@Youssef1313 I've opened a new pull request, #51526, to work on those changes. Once the pull request is ready, I'll request review from you. |
…guration support (#51526) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Youssef1313 <[email protected]>
Fixes #51398
Fixes #51481