Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass in genericParamProvider #555

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/DotNet/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,14 @@ TypeSig ImportAsTypeSig(Type type, Type declaringType, bool? treatAsGenericInst
case ElementType.SZArray: return new SZArraySig(ImportAsTypeSig(type.GetElementType(), declaringType));
case ElementType.ValueType: return new ValueTypeSig(CreateTypeDefOrRef(type));
case ElementType.Class: return new ClassSig(CreateTypeDefOrRef(type));
case ElementType.Var: return new GenericVar((uint)type.GenericParameterPosition, gpContext.Type);
case ElementType.MVar: return new GenericMVar((uint)type.GenericParameterPosition, gpContext.Method);
case ElementType.Var:
if (gpContext.Type is null && IsThisModule(type.Module) && module.ResolveToken(type.DeclaringType.MetadataToken) is TypeDef ownerType)
return new GenericVar((uint)type.GenericParameterPosition, ownerType);
return new GenericVar((uint)type.GenericParameterPosition, gpContext.Type);
case ElementType.MVar:
if (gpContext.Method is null && IsThisModule(type.Module) && module.ResolveToken(type.DeclaringMethod.MetadataToken) is MethodDef ownerMethod)
return new GenericMVar((uint)type.GenericParameterPosition, ownerMethod);
return new GenericMVar((uint)type.GenericParameterPosition, gpContext.Method);

case ElementType.I:
FixSignature = true; // FnPtr is mapped to System.IntPtr
Expand Down Expand Up @@ -827,11 +833,11 @@ public TypeSig Import(TypeSig type) {
case ElementType.ByRef: result = new ByRefSig(Import(type.Next)); break;
case ElementType.ValueType: result = CreateClassOrValueType((type as ClassOrValueTypeSig).TypeDefOrRef, true); break;
case ElementType.Class: result = CreateClassOrValueType((type as ClassOrValueTypeSig).TypeDefOrRef, false); break;
case ElementType.Var: result = new GenericVar((type as GenericVar).Number, gpContext.Type); break;
case ElementType.Var: result = new GenericVar((type as GenericVar).Number, gpContext.Type ?? (type as GenericVar).OwnerType); break;
CreateAndInject marked this conversation as resolved.
Show resolved Hide resolved
case ElementType.ValueArray:result = new ValueArraySig(Import(type.Next), (type as ValueArraySig).Size); break;
case ElementType.FnPtr: result = new FnPtrSig(Import((type as FnPtrSig).Signature)); break;
case ElementType.SZArray: result = new SZArraySig(Import(type.Next)); break;
case ElementType.MVar: result = new GenericMVar((type as GenericMVar).Number, gpContext.Method); break;
case ElementType.MVar: result = new GenericMVar((type as GenericMVar).Number, gpContext.Method ?? (type as GenericMVar).OwnerMethod); break;
case ElementType.CModReqd: result = new CModReqdSig(Import((type as ModifierSig).Modifier), Import(type.Next)); break;
case ElementType.CModOpt: result = new CModOptSig(Import((type as ModifierSig).Modifier), Import(type.Next)); break;
case ElementType.Module: result = new ModuleSig((type as ModuleSig).Index, Import(type.Next)); break;
Expand Down
Loading