コード例 #1
0
        protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, UnconfiguredProject providerState)
        {
            providerState.GetQueryDataVersion(out string versionKey, out long versionNumber);
            queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);

            return(PropertyPageDataProducer.CreatePropertyPageValuesAsync(queryExecutionContext, parent, providerState, _properties));
        }
コード例 #2
0
        public static async Task <IEntityValue?> CreatePropertyPageValueAsync(
            IQueryExecutionContext queryExecutionContext,
            EntityIdentity id,
            IProjectService2 projectService,
            IProjectStateProvider projectStateProvider,
            QueryProjectPropertiesContext propertiesContext,
            string propertyPageName,
            IPropertyPagePropertiesAvailableStatus requestedProperties)
        {
            if (projectService.GetLoadedProject(propertiesContext.File) is UnconfiguredProject project)
            {
                project.GetQueryDataVersion(out string versionKey, out long versionNumber);
                queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);

                if (await project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog &&
                    projectCatalog.GetSchema(propertyPageName) is Rule rule &&
                    !rule.PropertyPagesHidden)
                {
                    IProjectState projectState      = projectStateProvider.CreateState(project);
                    IEntityValue  propertyPageValue = CreatePropertyPageValue(queryExecutionContext, id, projectState, propertiesContext, rule, requestedProperties);
                    return(propertyPageValue);
                }
            }

            return(null);
        }
コード例 #3
0
        protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, ContextAndRuleProviderState providerState)
        {
            (string versionKey, long versionNumber) = providerState.ProjectState.GetUnconfiguredProjectVersion();
            queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);

            return(Task.FromResult(CategoryDataProducer.CreateCategoryValues(queryExecutionContext, parent, providerState.Rule, _properties)));
        }
コード例 #4
0
        protected override async Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, ContextAndRuleProviderState providerState)
        {
            if (await providerState.ProjectState.GetMetadataVersionAsync() is (string versionKey, long versionNumber))
            {
                queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);
            }

            return(UIPropertyDataProducer.CreateUIPropertyValues(queryExecutionContext, parent, providerState.ProjectState, providerState.PropertiesContext, providerState.Rule, _properties));
        }
コード例 #5
0
        public static async Task <IEnumerable <IEntityValue> > CreateUIPropertyValueValuesAsync(
            IQueryExecutionContext queryExecutionContext,
            IEntityValue parent,
            IProjectState cache,
            Rule schema,
            QueryProjectPropertiesContext propertiesContext,
            string propertyName,
            IUIPropertyValuePropertiesAvailableStatus requestedProperties)
        {
            BaseProperty?unboundProperty = schema.GetProperty(propertyName);

            if (unboundProperty is null)
            {
                return(ImmutableList <IEntityValue> .Empty);
            }

            ImmutableList <IEntityValue> .Builder builder = ImmutableList.CreateBuilder <IEntityValue>();

            IEnumerable <ProjectConfiguration> configurations;

            if (unboundProperty.IsConfigurationDependent())
            {
                // Return the values across all configurations.
                configurations = await cache.GetKnownConfigurationsAsync() ?? Enumerable.Empty <ProjectConfiguration>();
            }
            else
            {
                // Return the value from any one configuration.
                if (await cache.GetSuggestedConfigurationAsync() is ProjectConfiguration defaultConfiguration)
                {
                    configurations = CreateSingleItemEnumerable(defaultConfiguration);
                }
                else
                {
                    configurations = Enumerable.Empty <ProjectConfiguration>();
                }
            }

            foreach (ProjectConfiguration configuration in configurations)
            {
                if (await cache.GetDataVersionAsync(configuration) is (string versionKey, long versionNumber))
                {
                    queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);
                }

                if (await cache.BindToRuleAsync(configuration, schema.Name, propertiesContext) is IRule rule &&
                    rule.GetProperty(propertyName) is ProjectSystem.Properties.IProperty property)
                {
                    IEntityValue propertyValue = await CreateUIPropertyValueValueAsync(parent, configuration, property, requestedProperties);

                    builder.Add(propertyValue);
                }
            }

            return(builder.ToImmutable());
コード例 #6
0
        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);
                    }
                }
            }
        }
コード例 #7
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);
                    }
                }
            }
        }
コード例 #8
0
        protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, PropertyProviderState providerState)
        {
            (string versionKey, long versionNumber) = providerState.ProjectState.GetUnconfiguredProjectVersion();
            queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);

            return(UIPropertyValueDataProducer.CreateUIPropertyValueValuesAsync(
                       queryExecutionContext,
                       parent,
                       providerState.ProjectState,
                       providerState.ContainingRule,
                       providerState.PropertiesContext,
                       providerState.PropertyName,
                       _properties));
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
0
 public static void ReportProjectVersion(this IQueryExecutionContext queryExecutionContext, UnconfiguredProject unconfiguredProject)
 {
     unconfiguredProject.GetQueryDataVersion(out string versionKey, out long versionNumber);
     queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);
 }