Ejemplo n.º 1
0
        private async Task <IEntityValue?> CreateLaunchProfileValueAsync(IQueryExecutionContext queryExecutionContext, EntityIdentity id, QueryProjectPropertiesContext propertiesContext)
        {
            if (_projectService.GetLoadedProject(propertiesContext.File) is UnconfiguredProject project &&
                project.Services.ExportProvider.GetExportedValueOrDefault <ILaunchSettingsProvider>() is ILaunchSettingsProvider launchSettingsProvider &&
                project.Services.ExportProvider.GetExportedValueOrDefault <LaunchSettingsTracker>() is LaunchSettingsTracker launchSettingsTracker &&
                await project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog &&
                await launchSettingsProvider.WaitForFirstSnapshot(Timeout.Infinite) is ILaunchSettings launchSettings)
            {
                if (launchSettings is IVersionedLaunchSettings versionedLaunchSettings)
                {
                    queryExecutionContext.ReportInputDataVersion(launchSettingsTracker.VersionKey, versionedLaunchSettings.Version);
                }

                IProjectState projectState = new LaunchProfileProjectState(project, launchSettingsProvider, launchSettingsTracker);

                foreach ((int index, ProjectSystem.Debug.ILaunchProfile profile) in launchSettings.Profiles.WithIndices())
                {
                    if (StringComparers.LaunchProfileNames.Equals(profile.Name, propertiesContext.ItemName) &&
                        !Strings.IsNullOrEmpty(profile.CommandName))
                    {
                        foreach (Rule rule in DebugUtilities.GetDebugChildRules(projectCatalog))
                        {
                            if (rule.Metadata.TryGetValue("CommandName", out object?commandNameObj) &&
                                commandNameObj is string commandName &&
                                StringComparers.LaunchProfileCommandNames.Equals(commandName, profile.CommandName))
                            {
                                IEntityValue launchProfileValue = LaunchProfileDataProducer.CreateLaunchProfileValue(
                                    queryExecutionContext,
                                    id,
                                    propertiesContext,
                                    rule,
                                    index,
                                    projectState,
                                    _properties);
                                return(launchProfileValue);
                            }
                        }
                    }
                }
            }

            return(null);
        }
        private IEntityValue CreateLaunchProfileValue(IQueryExecutionContext queryExecutionContext, IEntityValue parent, QueryProjectPropertiesContext propertiesContext, Rule rule, int order, IProjectState projectState)
        {
            EntityIdentity identity = LaunchProfileDataProducer.CreateLaunchProfileId(parent, propertiesContext.ItemType !, propertiesContext.ItemName !);

            return(LaunchProfileDataProducer.CreateLaunchProfileValue(queryExecutionContext, identity, propertiesContext, rule, order, projectState, _properties));
        }