Exemplo n.º 1
0
        private ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = null)
        {
            _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", "");
            _mockFS.CreateDirectory(@"c:\test\Project");
            _mockFS.CreateDirectory(@"c:\test\Project\bin\");
            _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", "");

            _mockEnvironment.Setup(s => s.GetEnvironmentVariable("Path")).Returns(() => _Path);

            var project = UnconfiguredProjectFactory.Create(filePath: _ProjectFile);

            var outputTypeEnum = new PageEnumValue(new EnumValue()
            {
                Name = outputType
            });
            var data = new PropertyPageData()
            {
                Category     = ConfigurationGeneral.SchemaName,
                PropertyName = ConfigurationGeneral.OutputTypeProperty,
                Value        = outputTypeEnum
            };
            var projectProperties = ProjectPropertiesFactory.Create(project, data);

            if (properties == null)
            {
                properties = new Dictionary <string, string>()
                {
                    { "RunCommand", @"dotnet" },
                    { "RunArguments", "exec " + "\"" + @"c:\test\project\bin\project.dll" + "\"" },
                    { "RunWorkingDirectory", @"bin\" },
                    { "TargetFrameworkIdentifier", @".NetCoreApp" },
                    { "OutDir", @"c:\test\project\bin\" }
                };
            }
            var delegatePropertiesMock = IProjectPropertiesFactory
                                         .MockWithPropertiesAndValues(properties);

            var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object);

            var configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o =>
                                                                                 o.ProjectPropertiesProvider == delegateProvider);

            var configuredProject = Mock.Of <ConfiguredProject>(o =>
                                                                o.UnconfiguredProject == project &&
                                                                o.Services == configuredProjectServices);

            _mockTokenReplace.Setup(s => s.ReplaceTokensInProfileAsync(It.IsAny <ILaunchProfile>())).Returns <ILaunchProfile>(p => Task.FromResult(p));

            var activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>(o =>
                                                                               o.GetConfiguredProjectForActiveFrameworkAsync() == Task.FromResult(configuredProject));
            var debugProvider = new ConsoleDebugTargetsProvider(
                configuredProject,
                _mockTokenReplace.Object,
                _mockFS,
                _mockEnvironment.Object,
                activeDebugFramework,
                projectProperties);

            return(debugProvider);
        }
Exemplo n.º 2
0
        public Task <IEnumValue?> TryCreateEnumValueAsync(string userSuppliedValue)
        {
            var value = new PageEnumValue(new EnumValue {
                Name = userSuppliedValue, DisplayName = userSuppliedValue
            });

            return(Task.FromResult <IEnumValue?>(value));
        }
Exemplo n.º 3
0
        ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = null)
        {
            _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", "");
            _mockFS.CreateDirectory(@"c:\test\Project");
            _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", "");

            LaunchProfile activeProfile = new LaunchProfile()
            {
                Name = "MyApplication", CommandLineArgs = "--someArgs", ExecutablePath = @"c:\test\Project\someapp.exe"
            };

            _mockEnvironment.Setup(s => s.GetEnvironmentVariable("Path")).Returns(() => _Path);

            var project = IUnconfiguredProjectFactory.Create(null, null, _ProjectFile);

            var outputTypeEnum = new PageEnumValue(new EnumValue()
            {
                Name = outputType
            });
            var data = new PropertyPageData()
            {
                Category     = ConfigurationGeneral.SchemaName,
                PropertyName = ConfigurationGeneral.OutputTypeProperty,
                Value        = outputTypeEnum
            };
            var projectProperties = ProjectPropertiesFactory.Create(project, data);

            if (properties == null)
            {
                properties = new Dictionary <string, string>()
                {
                    { "TargetPath", @"c:\test\project\bin\project.dll" },
                    { "TargetFrameworkIdentifier", @".NetCoreApp" }
                };
            }
            var delegatePropertiesMock = IProjectPropertiesFactory
                                         .MockWithPropertiesAndValues(properties);

            var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object);

            IConfiguredProjectServices configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o =>
                                                                                                        o.ProjectPropertiesProvider == delegateProvider);

            ConfiguredProject configuredProject = Mock.Of <ConfiguredProject>(o =>
                                                                              o.UnconfiguredProject == project &&
                                                                              o.Services == configuredProjectServices);

            _mockTokenReplace.Setup(s => s.ReplaceTokensInProfileAsync(It.IsAny <ILaunchProfile>())).Returns <ILaunchProfile>(p => Task.FromResult(p));

            var debugProvider = new ConsoleDebugTargetsProvider(
                configuredProject,
                _mockTokenReplace.Object,
                _mockFS,
                _mockEnvironment.Object,
                projectProperties);

            return(debugProvider);
        }
Exemplo n.º 4
0
        private OutputTypeChecker CreateOutputTypeChecker(string outputType)
        {
            var project = UnconfiguredProjectFactory.Create(fullPath: _ProjectFile);

            var outputTypeEnum = new PageEnumValue(new EnumValue {
                Name = outputType
            });
            var data = new PropertyPageData(ConfigurationGeneral.SchemaName, ConfigurationGeneral.OutputTypeProperty, outputTypeEnum);
            var projectProperties = ProjectPropertiesFactory.Create(project, data);

            return(new OutputTypeChecker(projectProperties));
        }
            public async Task <ICollection <IEnumValue> > GetListedValuesAsync()
            {
                var enumValues = new List <IEnumValue>();
                var items      = await _projectXmlAccessor.GetItems(_configuredProject, itemType : SupportedTargetFrameworkItemName, metadataName : DisplayNameMetadataName).ConfigureAwait(false);

                foreach (var item in items)
                {
                    var val = new PageEnumValue(new EnumValue {
                        Name = item.evaluatedInclude, DisplayName = item.metadataValue
                    });
                    enumValues.Add(val);
                }

                return(enumValues);
            }
        private ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = null, IVsDebugger10 debugger = null)
        {
            _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", "");
            _mockFS.CreateDirectory(@"c:\test\Project");
            _mockFS.CreateDirectory(@"c:\test\Project\bin\");
            _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", "");

            var project = UnconfiguredProjectFactory.Create(filePath: _ProjectFile);

            var outputTypeEnum = new PageEnumValue(new EnumValue()
            {
                Name = outputType
            });
            var data = new PropertyPageData()
            {
                Category     = ConfigurationGeneral.SchemaName,
                PropertyName = ConfigurationGeneral.OutputTypeProperty,
                Value        = outputTypeEnum
            };
            var projectProperties = ProjectPropertiesFactory.Create(project, data);

            if (properties == null)
            {
                properties = new Dictionary <string, string>()
                {
                    { "RunCommand", @"dotnet" },
                    { "RunArguments", "exec " + "\"" + @"c:\test\project\bin\project.dll" + "\"" },
                    { "RunWorkingDirectory", @"bin\" },
                    { "TargetFrameworkIdentifier", @".NetCoreApp" },
                    { "OutDir", @"c:\test\project\bin\" }
                };
            }
            var delegatePropertiesMock = IProjectPropertiesFactory
                                         .MockWithPropertiesAndValues(properties);

            var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object);

            var configuredProjectServices = Mock.Of <ConfiguredProjectServices>(o =>
                                                                                o.ProjectPropertiesProvider == delegateProvider);

            var configuredProject = Mock.Of <ConfiguredProject>(o =>
                                                                o.UnconfiguredProject == project &&
                                                                o.Services == configuredProjectServices);
            var environment = IEnvironmentHelperFactory.ImplementGetEnvironmentVariable(_Path);

            return(CreateInstance(project: project, configuredProject: configuredProject, fileSystem: _mockFS, properties: projectProperties, environment: environment, debugger: debugger));
        }
Exemplo n.º 7
0
        private ManagedDebuggerImageTypeService CreateInstance(string outputType)
        {
            var outputTypeEnum = new PageEnumValue(new EnumValue()
            {
                Name = outputType
            });

            var data = new PropertyPageData()
            {
                Category     = ConfigurationGeneral.SchemaName,
                PropertyName = ConfigurationGeneral.OutputTypeProperty,
                Value        = outputTypeEnum
            };

            var project    = IUnconfiguredProjectFactory.Create();
            var properties = ProjectPropertiesFactory.Create(project, data);

            return(new ManagedDebuggerImageTypeService(properties));
        }