void CollectArray(IArrayTypeSymbol array) { var elemType = array.ElementType; CollectCore(elemType); var info = new GenericSerializationInfo { FullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), }; if (array.IsSZArray) { info.FormatterName = $"global::Brimborium.Latrans.JSON.Formatters.ArrayFormatter<{elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}>"; } else if (array.Rank == 2) { info.FormatterName = $"global::Brimborium.Latrans.JSON.Formatters.TwoDimentionalArrayFormatter<{elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}>"; } else if (array.Rank == 3) { info.FormatterName = $"global::Brimborium.Latrans.JSON.Formatters.ThreeDimentionalArrayFormatter<{elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}>"; } else if (array.Rank == 4) { info.FormatterName = $"global::Brimborium.Latrans.JSON.Formatters.FourDimentionalArrayFormatter<{elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}>"; } else { throw new InvalidOperationException("does not supports array dimention, " + info.FullName); } collectedGenericInfo.Add(info); return; }
static void MakeArray(IArrayTypeSymbol array, List <GenericSerializationInfo> list) { var arrayInfo = new GenericSerializationInfo { FormatterName = $"global::MessagePack.Formatters.ArrayFormatter<{array.ElementType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}>()", FullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), }; list.Add(arrayInfo); }
void CollectArray(IArrayTypeSymbol array) { var elemType = array.ElementType; CollectCore(elemType); var info = new GenericSerializationInfo { FormatterName = $"global::MessagePack.Formatters.ArrayFormatter<{elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}>", FullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), }; collectedGenericInfo.Add(info); return; }
private IEnumerable <Instruction> CreateNewArray(ArrayCreationExpressionSyntax syntaxNode, IArrayTypeSymbol arrayTypeSymbol, UcfgExpression callTarget) { expressionService.Associate(syntaxNode, callTarget); var instruction = new Instruction { NewObject = new NewObject { Location = syntaxNode.GetUcfgLocation(), Type = arrayTypeSymbol.ToDisplayString() } }; callTarget.ApplyAsTarget(instruction); return(new[] { instruction }); }
private bool CollectArray(IArrayTypeSymbol arraySymbol) { var elementType = arraySymbol.ElementType; Collect(elementType); if (!_formatters.TryGetValue(arraySymbol, out INamedTypeSymbol formatter) && _genericArrayFormatters.TryGetValue(arraySymbol.Rank, out formatter)) { formatter = formatter.Construct(elementType); _formatters.Add(arraySymbol, formatter); } if (formatter == null) { throw new InvalidOperationException($"Not supported array type {arraySymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}"); } _collected.Add(arraySymbol); return(true); }