Type.IsSZArray property.#16996
Conversation
| yield return new object[] {typeof(int), false}; | ||
| yield return new object[] {typeof(int[]).MakeByRefType(), false}; | ||
| yield return new object[] {typeof(int[,]), false}; | ||
| yield return new object[]{typeof(TypeTests), false }; |
| yield return new object[] {Array.CreateInstance(typeof(int), new[] {2}, new[] {0}).GetType(), true}; | ||
| yield return new object[] {typeof(int[][]), true}; | ||
| yield return new object[] { Type.GetType("System.Int32[]"), true }; | ||
| yield return new object[] { Type.GetType("System.Int32[*]"), false }; |
There was a problem hiding this comment.
typeof(int).MakeArrayType() and typeof(int).MakeArrayType(1) are a less roundable way to get these types than calling Type.GetType().
There was a problem hiding this comment.
My intention had been to arive at types in a few different ways even if they're the same implementation underneath, so I've added the MakeArrayType() approach, but left these in.
| yield return new object[] {Array.CreateInstance(typeof(int), new[] {2}, new[] {0}).GetType(), true}; | ||
| yield return new object[] {typeof(int[][]), true}; | ||
| yield return new object[] { Type.GetType("System.Int32[]"), true }; | ||
| yield return new object[] { Type.GetType("System.Int32[*]"), false }; |
There was a problem hiding this comment.
typeof(int).MakeArrayType() and typeof(int).MakeArrayType(1) are a less roundabout way to get these types than calling Type.GetType().
|
@dotnet-bot test this please |
|
That netfx failure is definitely related. Do I need to do something to make it work there, or do something to make the test not run there? |
I expect you need to guard the tests to only be compiled when targeting a build with the new surface area: |
7c00116 to
097a903
Compare
| arrType = enumBuilder.MakeArrayType(2); | ||
| Assert.True(arrType.IsArray); | ||
| Assert.False(arrType.IsSZArray); | ||
| } |
There was a problem hiding this comment.
Nit: in all of these tests, can you add blank lines between the relevant sets of tests, e.g.
Type asType = enumBuilder.AsType();
Assert.False(asType.IsArray);
Assert.False(asType.IsSZArray);
Type arrType = enumBuilder.MakeArrayType();
Assert.True(arrType.IsArray);
Assert.True(arrType.IsSZArray);I find it hard to read when it's all smushed together like this.
There was a problem hiding this comment.
It does suddenly look like a big block once you point that out! Changed.
Closes #16566
|
@dotnet-bot test Outerloop Windows_NT Debug please |
Type.IsSZArray property. Commit migrated from dotnet/corefx@2ab05c3
Closes #16566
Won't pass CI until dotnet/coreclr#10105 and corert implementation (pending) are in.