Skip to content

Commit 2c1019a

Browse files
committed
Fixed warning spam with built-in types.
1 parent 71de740 commit 2c1019a

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

CSharpToJavaScript/WithSemanticWalker.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -606,17 +606,17 @@ private bool BuiltInTypesGenerics(TypeSyntax node, ISymbol? symbol, out string s
606606
{
607607
str = string.Empty;
608608

609+
//We need a symbol, if it is null, return.
609610
if (symbol == null)
610611
{
611-
Log.WarningLine($"node: \"{node}\", symbol is null. USE \"CustomCSNamesToJS\"!");
612+
//Log.WarningLine($"node: \"{node}\", symbol is null. USE \"CustomCSNamesToJS\"!");
612613
return false;
613614
}
614-
if (symbol.Name == "dynamic")
615-
{
616-
//Hitting with "AllInOneNoPreprocessor-v6.cs"
617-
Log.WarningLine($"node: \"{node}\", symbol is \"dynamic\".");
615+
616+
//If symbol locations are zero, return. Treat as symbol null.
617+
//Also, if symbol in a source return, it is not a built-in type.
618+
if (symbol.Locations.Length == 0 || symbol.Locations[0].IsInSource)
618619
return false;
619-
}
620620

621621
ISymbol typeSymbol = symbol;
622622

@@ -625,40 +625,40 @@ private bool BuiltInTypesGenerics(TypeSyntax node, ISymbol? symbol, out string s
625625
typeSymbol = symbol.ContainingSymbol;
626626
if (typeSymbol == null)
627627
{
628-
Log.WarningLine($"node: \"{node}\", typeSymbol is null. USE \"CustomCSNamesToJS\"!");
628+
Log.WarningLine($"node: \"{node}\", symbol: \"{symbol}\", typeSymbol is null. USE \"CustomCSNamesToJS\"!");
629629
return false;
630630
}
631631

632632
if (typeSymbol.Kind != SymbolKind.NamedType)
633633
{
634-
//We are only interested in 'SymbolKind.NamedType'
635-
//so silently ignore and return.
636-
//TODO? Rewrite the whole method? Or just check for the kind at the beginning.
637-
638-
//Log.WarningLine($"node: \"{node}\", typeSymbol is \"{typeSymbol.Kind}\". USE \"CustomCSNamesToJS\"!");
634+
Log.WarningLine($"node: \"{node}\", symbol: \"{symbol}\", symbol kind: \"{symbol.Kind}\", typeSymbol kind: \"{typeSymbol.Kind}\". USE \"CustomCSNamesToJS\"!");
639635
return false;
640636
}
641637
}
642638

643639
string typeName = typeSymbol.Name;
644640

645641
string? jsStr = _NETAPI.ReturnJSString(typeName);
642+
646643
if (jsStr == null)
647644
{
648-
Log.WarningLine($"typeSymbol: \"{typeSymbol}\" Is not supported! USE \"CustomCSNamesToJS\"");
645+
Log.WarningLine($"typeName: \"{typeName}\", typeSymbol: \"{typeSymbol}\" Is not supported! USE \"CustomCSNamesToJS\"");
649646
return false;
650647
}
651648
else
652649
{
650+
//return early if the type name is the same as a symbol.
653651
if (typeName == symbol.Name)
654652
{
655653
str = jsStr;
656654
return true;
657655
}
656+
658657
jsStr = _NETAPI.ReturnJSString(typeName, symbol.Name);
658+
659659
if (jsStr == null)
660660
{
661-
Log.WarningLine($"node: \"{node}\", typeSymbol: \"{typeSymbol}\", symbol: \"{symbol}\", symbolName: \"{symbol.Name}\", Is not supported! USE \"CustomCSNamesToJS\"");
661+
Log.WarningLine($"node: \"{node}\", typeName: \"{typeName}\", typeSymbol: \"{typeSymbol}\", symbol: \"{symbol}\", symbolName: \"{symbol.Name}\", Is not supported! USE \"CustomCSNamesToJS\"");
662662
return false;
663663
}
664664
else

0 commit comments

Comments
 (0)