diff --git a/Rewrite/src/Rewrite.CSharp/CSharpTypeMapping.cs b/Rewrite/src/Rewrite.CSharp/CSharpTypeMapping.cs index 45b452d..424b6f6 100644 --- a/Rewrite/src/Rewrite.CSharp/CSharpTypeMapping.cs +++ b/Rewrite/src/Rewrite.CSharp/CSharpTypeMapping.cs @@ -78,6 +78,7 @@ private JavaType Type(IMethodSymbol methodSymbol) methodSymbol.Parameters.Select(Type).ToList(), null, null, + null, null ); } diff --git a/Rewrite/src/Rewrite.Java/Tree/JavaType.cs b/Rewrite/src/Rewrite.Java/Tree/JavaType.cs index 9b67b97..408892e 100644 --- a/Rewrite/src/Rewrite.Java/Tree/JavaType.cs +++ b/Rewrite/src/Rewrite.Java/Tree/JavaType.cs @@ -9,10 +9,11 @@ namespace Rewrite.RewriteJava.Tree; [SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")] public interface JavaType { - internal static JavaType[] EMPTY_JAVA_TYPE_ARRAY = []; - internal static FullyQualified[] EMPTY_FULLY_QUALIFIED_ARRAY = []; - internal static Method[] EMPTY_METHOD_ARRAY = []; - internal static Variable[] EMPTY_VARIABLE_ARRAY = []; + internal static readonly JavaType[] EMPTY_JAVA_TYPE_ARRAY = []; + internal static readonly FullyQualified[] EMPTY_FULLY_QUALIFIED_ARRAY = []; + internal static readonly Method[] EMPTY_METHOD_ARRAY = []; + internal static readonly Variable[] EMPTY_VARIABLE_ARRAY = []; + internal static readonly string[] EMPTY_STRING_ARRAY = []; internal int? ManagedReference => null; @@ -324,7 +325,7 @@ internal void UnsafeSet(IList? typeParameters, FullyQualified? superty IList? annotations, IList? interfaces, IList? members, IList? methods) { - + TypeParameters = typeParameters ?? EMPTY_JAVA_TYPE_ARRAY; Supertype = supertype; OwningClass = owningClass; @@ -531,9 +532,10 @@ public Method(int? managedReference, JavaType? returnType, IList? parameterNames, IList? parameterTypes, - IList? thrownExceptions, + IList? thrownExceptions, IList? annotations, - IList? defaultValue) + IList? defaultValue, + IList? declaredFormalTypeNames) { ManagedReference = managedReference; FlagsBitMap = flagsBitMap; @@ -542,9 +544,10 @@ public Method(int? managedReference, ReturnType = returnType ?? Unknown.Instance; ParameterNames = parameterNames ?? (Enumerable.Empty() as IList)!; ParameterTypes = parameterTypes ?? EMPTY_JAVA_TYPE_ARRAY; - ThrownExceptions = thrownExceptions ?? EMPTY_FULLY_QUALIFIED_ARRAY; + ThrownExceptions = thrownExceptions ?? EMPTY_JAVA_TYPE_ARRAY; Annotations = annotations ?? EMPTY_FULLY_QUALIFIED_ARRAY; DefaultValue = defaultValue; + DeclaredFormalTypeNames = declaredFormalTypeNames ?? EMPTY_STRING_ARRAY; } public int? ManagedReference { get; internal set; } @@ -573,11 +576,13 @@ public bool isConstructor() return "".Equals(Name); } - public IList ThrownExceptions { get; set; } = []; + public IList ThrownExceptions { get; set; } = []; public IList Annotations { get; internal set; } = []; public IList? DefaultValue { get; internal set; } = []; + + public IList? DeclaredFormalTypeNames { get; internal set; } = []; } public sealed class Variable : JavaType diff --git a/Rewrite/src/Rewrite.Remote.Codec/Java/Initialization.cs b/Rewrite/src/Rewrite.Remote.Codec/Java/Initialization.cs index 89adbe7..63c9d14 100644 --- a/Rewrite/src/Rewrite.Remote.Codec/Java/Initialization.cs +++ b/Rewrite/src/Rewrite.Remote.Codec/Java/Initialization.cs @@ -96,7 +96,7 @@ private static void RegisterValueDeserializers() break; case "thrownExceptions": reader.ReadStartArray(); - IList exceptions = []; + IList exceptions = []; while (reader.PeekState() != CborReaderState.EndArray) { exceptions.Add(context.Deserialize(reader)!); @@ -127,6 +127,17 @@ private static void RegisterValueDeserializers() reader.ReadEndArray(); method.DefaultValue = defaultValue; break; + case "declaredFormalTypeNames": + reader.ReadStartArray(); + IList declaredFormalTypeNames = []; + while (reader.PeekState() != CborReaderState.EndArray) + { + declaredFormalTypeNames.Add(reader.ReadTextString()); + } + + reader.ReadEndArray(); + method.DeclaredFormalTypeNames = declaredFormalTypeNames; + break; default: throw new NotImplementedException(prop); } @@ -491,6 +502,15 @@ private static void RegisterValueSerializers() writer.WriteEndArray(); } + if (value.DeclaredFormalTypeNames != null) + { + writer.WriteTextString("declaredFormalTypeNames"); + writer.WriteStartArray(value.DeclaredFormalTypeNames.Count); + foreach (var defaultValue in value.DeclaredFormalTypeNames) + writer.WriteTextString(defaultValue); + writer.WriteEndArray(); + } + writer.WriteEndMap(); }); RemotingContext.RegisterValueSerializer((value, type, writer, context) =>