protected override ProjectSettings LoadProjectSettings()
        {
            tracer.Trace("Discover project settings", "VsGeneratorServices");

            ProjectPlatformSettings projectPlatformSettings;
            var tergetLanguage = VsProjectScope.GetTargetLanguage(project);

            switch (tergetLanguage)
            {
            case ProgrammingLanguage.CSharp:
                projectPlatformSettings = new ProjectPlatformSettings
                {
                    Language        = GenerationTargetLanguage.CSharp,
                    LanguageVersion = new Version("3.0"),
                    Platform        = GenerationTargetPlatform.DotNet,
                    PlatformVersion = new Version("3.5"),
                };
                break;

            case ProgrammingLanguage.VB:
                projectPlatformSettings = new ProjectPlatformSettings
                {
                    Language        = GenerationTargetLanguage.VB,
                    LanguageVersion = new Version("9.0"),
                    Platform        = GenerationTargetPlatform.DotNet,
                    PlatformVersion = new Version("3.5"),
                };
                break;

            default:
                throw new NotSupportedException("target language not supported");
            }

            var configurationHolder = configurationReader.ReadConfiguration();

            return(new ProjectSettings
            {
                ProjectName = Path.GetFileNameWithoutExtension(project.FullName),
                AssemblyName = VsxHelper.GetProjectAssemblyName(project),
                ProjectFolder = VsxHelper.GetProjectFolder(project),
                DefaultNamespace = VsxHelper.GetProjectDefaultNamespace(project),
                ProjectPlatformSettings = projectPlatformSettings,
                ConfigurationHolder = configurationHolder
            });
        }
Exemple #2
0
        private GeneratorConfiguration GenGeneratorConfig()
        {
            try
            {
                //TODO: have a "project context" where the actual confic can be read without re-loading/parsing it.
                var configurationHolder = configurationReader.ReadConfiguration();
                var config = new GeneratorConfigurationProvider().LoadConfiguration(configurationHolder);
                if (config == null)
                {
                    return(new GeneratorConfiguration());
                }

                return(config.GeneratorConfiguration);
            }
            catch (Exception exception)
            {
                tracer.Trace("Config load error: " + exception, "VsGeneratorInfoProvider");
                return(new GeneratorConfiguration());
            }
        }