public static IEntityValue CreateCategoryValue(IEntityValue parent, Rule rule, Category category, int order, ICategoryPropertiesAvailableStatus requestedProperties)
        {
            Requires.NotNull(parent, nameof(parent));
            Requires.NotNull(category, nameof(category));

            string categoryName = DebugUtilities.GetDebugCategoryNameOrNull(rule, category) ?? category.Name;

            var identity = new EntityIdentity(
                ((IEntityWithId)parent).Id,
                new KeyValuePair <string, string>[]
            {
                new(ProjectModelIdentityKeys.CategoryName, categoryName)
            });
        public static IEntityValue CreateUIPropertyValue(IEntityValue parent, IPropertyPageQueryCache cache, BaseProperty property, int order, IUIPropertyPropertiesAvailableStatus requestedProperties)
        {
            Requires.NotNull(parent, nameof(parent));
            Requires.NotNull(property, nameof(property));

            string propertyName = DebugUtilities.GetDebugPropertyNameOrNull(property) ?? property.Name;

            var identity = new EntityIdentity(
                ((IEntityWithId)parent).Id,
                new KeyValuePair <string, string>[]
            {
                new(ProjectModelIdentityKeys.UIPropertyName, propertyName)
            });
        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);
                    }
                }
            }
        }
示例#4
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);
                    }
                }
            }
        }
示例#5
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);
        }
        public static IEntityValue CreatePropertyPageValue(IEntityValue parent, IPropertyPageQueryCache cache, Rule rule, List <Rule>?debugChildRules, IPropertyPagePropertiesAvailableStatus requestedProperties)
        {
            Requires.NotNull(parent, nameof(parent));
            Requires.NotNull(rule, nameof(rule));

            string name = rule.PageTemplate == "debuggerParent"
                ? DebugUtilities.ConvertRealPageNameToDebugPageName(rule.Name)
                : rule.Name;

            var identity = new EntityIdentity(
                ((IEntityWithId)parent).Id,
                new KeyValuePair <string, string>[]
            {
                new(ProjectModelIdentityKeys.PropertyPageName, name)
            });
示例#7
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);
        }