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

Make TypeBuilder.CreateType return non nullable #72180

Merged
merged 16 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ private void CreateGlobalFunctionsNoLock()
// cannot create globals twice
throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule);
}
_globalTypeBuilder.CreateType();
_globalTypeBuilder.CreateTypeImpl();
_hasGlobalBeenCreated = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ private void SetGenParamCustomAttributeNoLock(CustAttr ca)
m_ca ??= new List<TypeBuilder.CustAttr>();
m_ca.Add(ca);
}

buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
#endregion

#region Object Overrides
Expand Down Expand Up @@ -1686,7 +1687,15 @@ private EventBuilder DefineEventNoLock(string name, EventAttributes attributes,
}
jkotas marked this conversation as resolved.
Show resolved Hide resolved

[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
public Type? CreateType()
public Type CreateType()
{
Type? type = CreateTypeImpl();
Debug.Assert(type != null);
return type;
}

[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
internal Type? CreateTypeImpl()
{
lock (SyncRoot)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internal EnumBuilder() { }
public System.Reflection.Emit.FieldBuilder UnderlyingField { get { throw null; } }
public override System.Type UnderlyingSystemType { get { throw null; } }
[return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
public System.Type? CreateType() { throw null; }
public System.Type CreateType() { throw null; }
[return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)]
public System.Reflection.TypeInfo? CreateTypeInfo() { throw null; }
public System.Reflection.Emit.FieldBuilder DefineLiteral(string literalName, object? literalValue) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void CreateType(TypeAttributes attributes)

TypeInfo typeInfo = type.CreateTypeInfo();
Assert.Equal(typeInfo, createdType.GetTypeInfo());
Assert.NotNull(createdType);
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved

// Verify MetadataToken
Assert.Equal(type.MetadataToken, typeInfo.MetadataToken);
Expand Down