예제 #1
0
        internal Symbol XSharpResolveEqualSymbols(Symbol first, Symbol second, ImmutableArray <Symbol> originalSymbols, CSharpSyntaxNode where, DiagnosticBag diagnostics)
        {
            CSDiagnosticInfo info;

            if (first.IsFromCompilation(Compilation) && !second.IsFromCompilation(Compilation))
            {
                info = new CSDiagnosticInfo(ErrorCode.WRN_VulcanAmbiguous, originalSymbols,
                                            new object[] {
                    where,
                    first.Kind.ToString(),
                    new FormattedSymbol(first, SymbolDisplayFormat.CSharpErrorMessageFormat),
                    second.Kind.ToString(),
                    new FormattedSymbol(second, SymbolDisplayFormat.CSharpErrorMessageFormat)
                });
                diagnostics.Add(info, where.Location);
                return(first);
            }
            else if (second.IsFromCompilation(Compilation) && !first.IsFromCompilation(Compilation))
            {
                info = new CSDiagnosticInfo(ErrorCode.WRN_VulcanAmbiguous, originalSymbols,
                                            new object[] {
                    where,
                    first.Kind.ToString(),
                    new FormattedSymbol(second, SymbolDisplayFormat.CSharpErrorMessageFormat),
                    second.Kind.ToString(),
                    new FormattedSymbol(first, SymbolDisplayFormat.CSharpErrorMessageFormat)
                });
                diagnostics.Add(info, where.Location);
                return(second);
            }
            else if (first.Kind == second.Kind &&
                     !string.Equals(first.Name, second.Name) &&
                     string.Equals(first.Name, second.Name, StringComparison.OrdinalIgnoreCase))
            {
                // they only differ in case
                info = new CSDiagnosticInfo(ErrorCode.WRN_VulcanAmbiguous, originalSymbols,
                                            new object[] {
                    where,
                    first.Kind.ToString(),
                    new FormattedSymbol(first, SymbolDisplayFormat.CSharpErrorMessageFormat),
                    second.Kind.ToString(),
                    new FormattedSymbol(second, SymbolDisplayFormat.CSharpErrorMessageFormat)
                });
                diagnostics.Add(info, where.Location);
                return(first);
            }
            else
            {
                info = new CSDiagnosticInfo(ErrorCode.WRN_VulcanAmbiguous, originalSymbols,
                                            new object[] {
                    where,
                    first.Kind.ToString(),
                    new FormattedSymbol(first, SymbolDisplayFormat.CSharpErrorMessageFormat),
                    second.Kind.ToString(),
                    new FormattedSymbol(second, SymbolDisplayFormat.CSharpErrorMessageFormat)
                });
                diagnostics.Add(info, where.Location);
                return(first);
            }
        }