Пример #1
0
        internal static Imports ExpandPreviousSubmissionImports(Imports previousSubmissionImports, CSharpCompilation newSubmission)
        {
            if (previousSubmissionImports == Empty)
            {
                return(Empty);
            }

            Debug.Assert(previousSubmissionImports != null);
            Debug.Assert(newSubmission.IsSubmission);

            var expandedAliases = ImmutableDictionary <string, AliasAndUsingDirective> .Empty;

            if (!previousSubmissionImports.UsingAliases.IsEmpty)
            {
                var expandedAliasesBuilder = ImmutableDictionary.CreateBuilder <string, AliasAndUsingDirective>();
                foreach (var pair in previousSubmissionImports.UsingAliases)
                {
                    var name      = pair.Key;
                    var directive = pair.Value;
                    expandedAliasesBuilder.Add(name, new AliasAndUsingDirective(directive.Alias.ToNewSubmission(newSubmission), directive.UsingDirective));
                }
                expandedAliases = expandedAliasesBuilder.ToImmutable();
            }

            var expandedUsings = ExpandPreviousSubmissionImports(previousSubmissionImports.Usings, newSubmission);

            return(Imports.Create(
                       expandedAliases,
                       expandedUsings,
                       previousSubmissionImports.ExternAliases));
        }
Пример #2
0
        internal Imports Concat(Imports otherImports)
        {
            Debug.Assert(otherImports != null);

            if (this == Empty)
            {
                return(otherImports);
            }

            if (otherImports == Empty)
            {
                return(this);
            }

            var usingAliases  = this.UsingAliases.SetItems(otherImports.UsingAliases); // NB: SetItems, rather than AddRange
            var usings        = this.Usings.AddRange(otherImports.Usings).Distinct(UsingTargetComparer.Instance);
            var externAliases = ConcatExternAliases(this.ExternAliases, otherImports.ExternAliases);

            return(Imports.Create(usingAliases, usings, externAliases));
        }
Пример #3
0
 protected override Imports GetImports()
 {
     return(Imports.Create(ImmutableDictionary <string, AliasAndUsingDirective> .Empty, _usings, ImmutableArray <AliasAndExternAliasDirective> .Empty));
 }