Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Class with T[] generic array field does not compile #1016

Open
wizzard0 opened this issue Sep 4, 2016 · 2 comments
Open

Class with T[] generic array field does not compile #1016

wizzard0 opened this issue Sep 4, 2016 · 2 comments
Labels

Comments

@wizzard0
Copy link

wizzard0 commented Sep 4, 2016

JSIL version b4f2ff8

    [Serializable]
    [JSProxy("System.ArraySegment`1")]
    public class ArraySegment<T> //: IList<T>, IReadOnlyList<T>
    {
        private T[] _arrayRef;
        public ArraySegment(T[] array, int offset, int count) { }
    }

-->

// Writing JS   System.Exception: Error occurred while generating javascript for assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. ---> System.Exception: An error occurred while declaring the type 'Syst
em.ArraySegment`1' ---> System.NotImplementedException: Unimplemented form of generic type parameter: 'T'.
   at JSIL.Internal.JavascriptFormatter.TypeReferenceInternal(GenericParameter gp, TypeReferenceContext context) in C:\dev\JSIL\JSIL\JavascriptFormatter.cs:line 578
   at JSIL.Internal.JavascriptFormatter.TypeReference(TypeReference type, TypeReferenceContext context) in C:\dev\JSIL\JSIL\JavascriptFormatter.cs:line 775
   at JSIL.Internal.JavascriptFormatter.TypeReferenceInternal(ArrayType at, TypeReferenceContext context) in C:\dev\JSIL\JSIL\JavascriptFormatter.cs:line 708
   at JSIL.Internal.JavascriptFormatter.TypeReference(TypeReference type, TypeReferenceContext context) in C:\dev\JSIL\JSIL\JavascriptFormatter.cs:line 777
   at JSIL.JavascriptAssemblyEmitter.EmitFieldOrConstant(DecompilerContext context, IAstEmitter astEmitter, FieldDefinition field, JSRawOutputIdentifier dollar, JSExpression defaultValue, Boolean isConstant) in C:\dev\JSIL\JSIL\JavascriptAs
semblyEmitter.cs:line 1207
   at JSIL.JavascriptAssemblyEmitter.EmitField(DecompilerContext context, IAstEmitter astEmitter, FieldDefinition field, JSRawOutputIdentifier dollar, JSExpression defaultValue) in C:\dev\JSIL\JSIL\JavascriptAssemblyEmitter.cs:line 1366
   at JSIL.AssemblyTranslator.<>c__DisplayClass107_0.<TranslateTypeStaticConstructor>b__10(FieldDefinition fd) in C:\dev\JSIL\JSIL\AssemblyTranslator.cs:line 1906
   at JSIL.AssemblyTranslator.TranslateTypeStaticConstructor(DecompilerContext context, TypeDefinition typedef, IAstEmitter astEmitter, IAssemblyEmitter assemblyEmitter, MethodDefinition cctor, Boolean stubbed, JSRawOutputIdentifier dollar,
 Cachers cachers) in C:\dev\JSIL\JSIL\AssemblyTranslator.cs:line 1931
   at JSIL.AssemblyTranslator.TranslateTypeDefinition(DecompilerContext context, TypeDefinition typedef, IAstEmitter astEmitter, IAssemblyEmitter assemblyEmitter, Boolean stubbed, JSRawOutputIdentifier dollar, Cachers cachers) in C:\dev\JSI
L\JSIL\AssemblyTranslator.cs:line 1298
   at JSIL.AssemblyTranslator.DeclareType(DecompilerContext context, TypeDefinition typedef, IAstEmitter astEmitter, IAssemblyEmitter assemblyEmitter, HashSet`1 declaredTypes, Boolean stubbed, Boolean isImported) in C:\dev\JSIL\JSIL\Assembl
yTranslator.cs:line 1126
   --- End of inner exception stack trace ---
   at JSIL.AssemblyTranslator.DeclareType(DecompilerContext context, TypeDefinition typedef, IAstEmitter astEmitter, IAssemblyEmitter assemblyEmitter, HashSet`1 declaredTypes, Boolean stubbed, Boolean isImported) in C:\dev\JSIL\JSIL\Assembl
yTranslator.cs:line 1142
   at JSIL.AssemblyTranslator.TranslateModule(DecompilerContext context, IAssemblyEmitter assemblyEmitter, ModuleDefinition module, HashSet`1 sealedTypes, HashSet`1 declaredTypes, Boolean stubbed) in C:\dev\JSIL\JSIL\AssemblyTranslator.cs:l
ine 1026
   at JSIL.AssemblyTranslator.TranslateSingleAssemblyInternal(IAssemblyEmitter assemblyEmitter, DecompilerContext context, AssemblyDefinition assembly, Stream outputStream, SourceMapBuilder sourceMapBuilder) in C:\dev\JSIL\JSIL\AssemblyTran
slator.cs:line 938
   at JSIL.AssemblyTranslator.<>c__DisplayClass79_0.<TranslateInternal>b__1(Int32 i) in C:\dev\JSIL\JSIL\AssemblyTranslator.cs:line 546
   --- End of inner exception stack trace ---
   at JSIL.AssemblyTranslator.<>c__DisplayClass79_0.<TranslateInternal>b__1(Int32 i) in C:\dev\JSIL\JSIL\AssemblyTranslator.cs:line 550
   at JSIL.AssemblyTranslator.TranslateInternal(String assemblyPath, Boolean scanForProxies) in C:\dev\JSIL\JSIL\AssemblyTranslator.cs:line 580
   at JSIL.AssemblyTranslator.Translate(String assemblyPath, Boolean scanForProxies) in C:\dev\JSIL\JSIL\AssemblyTranslator.cs:line 452
   at JSIL.Compiler.Profiles.BaseProfile.Translate(VariableSet variables, AssemblyTranslator translator, Configuration configuration, String assemblyPath, Boolean scanForProxies) in C:\dev\JSIL\Compiler\Profiles\Base.cs:line 19
   at JSIL.Compiler.Program.InternalMain(String[] arguments) in C:\dev\JSIL\Compiler\Program.cs:line 821
   at JSIL.Compiler.Program.Main(String[] arguments) in C:\dev\JSIL\Compiler\Program.cs:line 699
Press any key to continue . . .
@kg kg added the Bug label Sep 4, 2016
@iskiselev
Copy link
Member

I believe there are some problems with proxy for generic classes. There should not be any problem if you just mark it all class or methods with JSExternalAttribute and implement it yourself with javascript.

@iskiselev
Copy link
Member

Could you provide full case to reproduce?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants