public async Task InitializeSourceAsync(Project project)
    {
        // TODO: Don't throw away solution-wide effects - write them to referencing files, and use in conversion of any other projects being converted at the same time.
        project = await ClashingMemberRenamer.RenameClashingSymbolsAsync(project);

        _convertedVbProject = project.ToProjectFromAnyOptions(_vbCompilationOptions, _vbParseOptions);
        _vbReferenceProject = project.CreateReferenceOnlyProjectFromAnyOptions(_vbCompilationOptions, _vbParseOptions);
        _vbViewOfCsSymbols  = (VisualBasicCompilation)await _vbReferenceProject.GetCompilationAsync(_cancellationToken);

        SourceProject = project;
    }
Exemplo n.º 2
0
    public async Task InitializeSourceAsync(Project project)
    {
        project = await ClashingMemberRenamer.RenameClashingSymbolsAsync(project);

        var cSharpCompilationOptions = CSharpCompiler.CreateCompilationOptions();

        _convertedCsProject     = project.ToProjectFromAnyOptions(cSharpCompilationOptions, CSharpCompiler.ParseOptions);
        _csharpReferenceProject = project.CreateReferenceOnlyProjectFromAnyOptions(cSharpCompilationOptions, CSharpCompiler.ParseOptions);
        _csharpViewOfVbSymbols  = (CSharpCompilation)await _csharpReferenceProject.GetCompilationAsync(_cancellationToken);

        _designerToResxRelativePath = project.ReadVbEmbeddedResources().ToDictionary(r => r.LastGenOutput, r => r.RelativePath);
        SourceProject = await WithProjectLevelWinformsAdjustmentsAsync(project);

        var compilation = await project.GetCompilationAsync(_cancellationToken);

#pragma warning disable RS1024 // Compare symbols correctly - analzyer bug, I'm intentionally using my own comparer, not the default ambiguous one. The default comparer wouldn't manage with cross-compilation comparison in all cases
        _typeToInheritors = compilation.GetAllNamespacesAndTypes().OfType <ITypeSymbol>()
                            .Where(t => t.BaseType?.IsDefinedInSource() == true)
                            .ToLookup(t => t.BaseType, TypeSymbolFullNameComparer.Instance);
#pragma warning restore RS1024 // Compare symbols correctly
    }