public async Task Initialize(Project project)
        {
            _sourceCsProject = project;
            var cSharpCompilationOptions = VisualBasicCompiler.CreateCompilationOptions(RootNamespace);

            _visualBasicParseOptions = VisualBasicParseOptions.Default;
            _convertedVbProject      = project.ToProjectFromAnyOptions(cSharpCompilationOptions, _visualBasicParseOptions);
            _vbViewOfCsSymbols       = (VisualBasicCompilation)await project.CreateReferenceOnlyCompilationFromAnyOptionsAsync(cSharpCompilationOptions);
        }
Ejemplo n.º 2
0
        private SourceCodeService CreateServiceWithRealCompiler(IFeatureToggle featureToggle = null)
        {
            ILogger logger = CreateLogger();
            ISourceFileGeneratorProvider sourceFileGeneratorProvider = CreateSourceFileGeneratorProvider();

            sourceFileGeneratorProvider
            .CreateSourceFileGenerator(Arg.Is(TargetLanguage.VisualBasic))
            .Returns(new VisualBasicSourceFileGenerator(logger));

            VisualBasicCompiler vbCompiler      = new VisualBasicCompiler(logger);
            CompilerFactory     compilerFactory = new CompilerFactory(null, vbCompiler);

            return(CreateSourceCodeService(sourceFileGeneratorProvider: sourceFileGeneratorProvider, calculationsRepository: Substitute.For <ICalculationsRepository>(), logger: logger, compilerFactory: compilerFactory));
        }
        public CSToVBProjectContentsConverter(ConversionOptions conversionOptions)
        {
            var vbCompilationOptions =
                (VisualBasicCompilationOptions)conversionOptions.TargetCompilationOptionsOverride ??
                VisualBasicCompiler.CreateCompilationOptions(conversionOptions.RootNamespaceOverride);

            if (conversionOptions.RootNamespaceOverride != null)
            {
                vbCompilationOptions = vbCompilationOptions.WithRootNamespace(conversionOptions.RootNamespaceOverride);
            }

            _vbCompilationOptions = vbCompilationOptions;
            _vbParseOptions       = VisualBasicParseOptions.Default;
            RootNamespace         = conversionOptions.RootNamespaceOverride;
        }
Ejemplo n.º 4
0
        public CSToVBProjectContentsConverter(ConversionOptions conversionOptions, IProgress <ConversionProgress> progress, CancellationToken cancellationToken)
        {
            _progress          = progress;
            _cancellationToken = cancellationToken;
            var vbCompilationOptions =
                (VisualBasicCompilationOptions)conversionOptions.TargetCompilationOptionsOverride ??
                VisualBasicCompiler.CreateCompilationOptions(conversionOptions.RootNamespaceOverride);

            if (conversionOptions.RootNamespaceOverride != null)
            {
                vbCompilationOptions = vbCompilationOptions.WithRootNamespace(conversionOptions.RootNamespaceOverride);
            }

            _vbCompilationOptions = vbCompilationOptions;
            _vbParseOptions       = VisualBasicCompiler.ParseOptions;
            RootNamespace         = conversionOptions.RootNamespaceOverride;
        }
    public CSToVBProjectContentsConverter(ConversionOptions conversionOptions, IProgress <ConversionProgress> progress, CancellationToken cancellationToken)
    {
        _cancellationToken = cancellationToken;
        OptionalOperations = new OptionalOperations(conversionOptions.AbandonOptionalTasksAfter, progress, cancellationToken);
        var vbCompilationOptions =
            (VisualBasicCompilationOptions)conversionOptions.TargetCompilationOptionsOverride ??
            VisualBasicCompiler.CreateCompilationOptions(conversionOptions.RootNamespaceOverride)
            .WithParseOptions(VisualBasicCompiler.ParseOptions);

        if (conversionOptions.RootNamespaceOverride != null)
        {
            vbCompilationOptions = vbCompilationOptions.WithRootNamespace(conversionOptions.RootNamespaceOverride);
        }

        _vbCompilationOptions = vbCompilationOptions;
        _vbParseOptions       = vbCompilationOptions.ParseOptions;
        RootNamespace         = conversionOptions.RootNamespaceOverride;
    }
 public CompilerFactory(CSharpCompiler cSharpCompiler, VisualBasicCompiler visualBasicCompiler)
 {
     _compilers.Add(".csproj", cSharpCompiler);
     _compilers.Add(".vbproj", visualBasicCompiler);
 }