Add/update AssemblyBuilder/PersistedAssemblyBuilder tests covering boundary / edge case scenarios#105782
Add/update AssemblyBuilder/PersistedAssemblyBuilder tests covering boundary / edge case scenarios#105782steveharter merged 5 commits intodotnet:mainfrom
Conversation
| _attributes = attributes; | ||
| _callingConvention = callingConvention; | ||
| _propertyType = returnType; | ||
| _propertyType = returnType ?? containingType.GetModuleBuilder().GetTypeFromCoreAssembly(CoreTypeId.Void); |
There was a problem hiding this comment.
Existing AssemblyBuilder adds void type for null return type when populating the signature, now this scenario causing NRE in the SignatureHelper, I could fix it in the signature only, but to avoid NRE's for other case setting the return type to void here.
There was a problem hiding this comment.
The constructor parameter, Type returnType isn't marked as nullable. If a null value is sneaking through, we should fix that or mark the parameter as nullable.
There was a problem hiding this comment.
Yes, allowing null might was not intentional, but making it throw for null now probably will be breaking change. We might also want to move the null handling from SignatureHelper to RuntimePropertyBuilder
There was a problem hiding this comment.
Sure, that makes sense. I don't think we should throw either, but I do like to have the nullable indicators correct so we can check these things.
There was a problem hiding this comment.
Existing AssemblyBuilder adds void type for null return type when populating the signature,
I assume this behavior exists in previous versions as well?
There was a problem hiding this comment.
Yes, RuntimePropertyBuilder constructor was allowing null, but not handling null which could cause NRE further if SetConstant called for the property, the null has been resolved only for GetPropertySigHelper. I see same behavior in .NET framework.
Now with this PR the null return type will be handled to void type in the RuntimePropertyBuilder constructor, same as in GetPropertySigHelper.
src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineField.cs
Show resolved
Hide resolved
steveharter
left a comment
There was a problem hiding this comment.
Some misc questions, but otherwise LGTM
|
Buyaa out, merged. |
It was considered useful to add tests for the following cases:
Fixes #103086