private async Task <IEnumerable <IEntityValue> > CreateLaunchProfileValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, UnconfiguredProject project)
        {
            if (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)
            {
                return(createLaunchProfileValues());
            }

            return(Enumerable.Empty <IEntityValue>());

            IEnumerable <IEntityValue> createLaunchProfileValues()
            {
                Dictionary <string, Rule> debugRules = new();

                foreach (Rule rule in DebugUtilities.GetDebugChildRules(projectCatalog))
                {
                    if (rule.Metadata.TryGetValue("CommandName", out object?commandNameObj) &&
                        commandNameObj is string commandName)
                    {
                        debugRules[commandName] = rule;
                    }
                }

                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 (!Strings.IsNullOrEmpty(profile.Name) &&
                        !Strings.IsNullOrEmpty(profile.CommandName) &&
                        debugRules.TryGetValue(profile.CommandName, out Rule rule))
                    {
                        QueryProjectPropertiesContext propertiesContext = new(
                            isProjectFile : true,
                            file : project.FullPath,
                            itemType : LaunchProfileProjectItemProvider.ItemType,
                            itemName : profile.Name);

                        IEntityValue launchProfileValue = CreateLaunchProfileValue(queryExecutionContext, parent, propertiesContext, rule, index, projectState);
                        yield return(launchProfileValue);
                    }
                }
            }
        }
Exemple #2
0
        public async Task <IEnumerable <IEntityValue> > RetrieveAllLaunchProfileEntitiesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, ILaunchProfilePropertiesAvailableStatus requestedProperties)
        {
            if (await _project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog)
            {
                ILaunchSettings launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot();

                return(createLaunchProfileValues(launchSettings));
            }

            return(Enumerable.Empty <IEntityValue>());

            IEnumerable <IEntityValue> createLaunchProfileValues(ILaunchSettings launchSettings)
            {
                Dictionary <string, Rule> debugRules = new();

                foreach (Rule rule in DebugUtilities.GetDebugChildRules(projectCatalog))
                {
                    if (rule.Metadata.TryGetValue(s_commandNameMetadataName, out object?commandNameObj) &&
                        commandNameObj is string commandName)
                    {
                        debugRules[commandName] = rule;
                    }
                }

                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 (!Strings.IsNullOrEmpty(profile.Name) &&
                        !Strings.IsNullOrEmpty(profile.CommandName) &&
                        debugRules.TryGetValue(profile.CommandName, out Rule rule))
                    {
                        QueryProjectPropertiesContext propertiesContext = new(
                            isProjectFile : true,
                            file : _project.FullPath,
                            itemType : LaunchProfileProjectItemProvider.ItemType,
                            itemName : profile.Name);

                        EntityIdentity id = CreateLaunchProfileId(parent, profile.Name);
                        IEntityValue   launchProfileValue = CreateLaunchProfileValue(queryExecutionContext, id, propertiesContext, rule, index, projectState, requestedProperties);
                        yield return(launchProfileValue);
                    }
                }
            }
        }
Exemple #3
0
        public async Task <IEntityValue?> RetrieveLaunchProfileEntityAsync(IQueryExecutionContext queryExecutionContext, EntityIdentity id, ILaunchProfilePropertiesAvailableStatus requestedProperties)
        {
            string desiredProfileName = ValidateIdAndExtractProfileName(id);

            if (await _project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog)
            {
                ILaunchSettings launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot();

                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, desiredProfileName) &&
                            !Strings.IsNullOrEmpty(profile.CommandName))
                        {
                            foreach (Rule rule in DebugUtilities.GetDebugChildRules(projectCatalog))
                            {
                                if (rule.Metadata.TryGetValue(s_commandNameMetadataName, out object?commandNameObj) &&
                                    commandNameObj is string commandName &&
                                    StringComparers.LaunchProfileCommandNames.Equals(commandName, profile.CommandName))
                                {
                                    QueryProjectPropertiesContext propertiesContext = new(
                                        isProjectFile : true,
                                        file : _project.FullPath,
                                        itemType : LaunchProfileProjectItemProvider.ItemType,
                                        itemName : profile.Name);

                                    IEntityValue launchProfileValue = CreateLaunchProfileValue(
                                        queryExecutionContext,
                                        id,
                                        propertiesContext,
                                        rule,
                                        index,
                                        projectState,
                                        requestedProperties);
                                    return(launchProfileValue);
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
Exemple #4
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);
        }