Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

JonHanna
Copy link
Contributor

@JonHanna JonHanna commented Apr 3, 2017

Handle dynamic containing non-SZ single-rank arrays.

Fixes #17808

Correct names of array types in dynamic-related error messages.

Fixes #17809

// Add [] with (rank-1) commas inside
ErrAppendChar('[');

#if ! CSEE
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone know what this CSEE constant refers to?

Copy link
Contributor

@OmarTawfik OmarTawfik Apr 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@OmarTawfik OmarTawfik Apr 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we need to find out why would the result be different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the CSEE behaviour is what I'd think would be correct for any case (except that it doesn't handle single-ranked non-SZ arrays but the assembly as a whole had no concept of SZ/non-SZ distinction before this PR).

In other cases I'm not sure what to do when I come across it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to be pieces that supports Expression Evaluator that is used at debug time. They make no sense in the dynamic binder code.
I guess they were just ported together with the rest of the code. Perhaps the initial pass used some automated translator and it picked up everything, or it was expected that there would be a need for a special binder - specifically for EE to call into, but that need never materialized...

Anyways, I am not aware of any CSEE flavor of the runtime binder.
The "CSEE" seems just dead code and can/should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that soon, so.

{
// Now we return an array of nesting level corresponding to the rank.
ctype = _typeManager.GetArray(GetCTypeFromType(t.GetElementType()), t.GetArrayRank());
ctype = _typeManager.GetArray(GetCTypeFromType(t.GetElementType()), t.GetArrayRank(), t.IsSZArray);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this use of IsSZArray going to be safe when building for netstandard, or do I need to conditionally bring in a kludge for that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. It seems I need to kludge.

d[3] = 32;
d[-1] = 28;
Assert.Equal(32, d[3]);
Assert.Equal(28, d[-1]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case is an interesting side-effect in that it's not possible to do compile the static equivalent, and yet the usage here seems reasonable and so not worth the explicit prohibition it would require to refuse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, one can currently do the equivalent with non-zero-based arrays of higher ranks, so prohibiting it here would have to either be a breaking change to that or else inconsistent with it.

@JonHanna JonHanna force-pushed the dynamic_arrays branch 2 times, most recently from ef26e47 to 3f1ae36 Compare April 3, 2017 13:25
@danmoseley danmoseley requested review from OmarTawfik and VSadov April 4, 2017 00:53
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);netcoreapp</DefineConstants>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Debug|AnyCPU'" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the change seems ok, but not sure about the project/solution changes.
If we need that, perhaps make them a separate change?

@JonHanna
Copy link
Contributor Author

JonHanna commented Apr 6, 2017

@VSadov This is now exactly as it was except for the .sln, .csprog and .props files being unchanged.

The #if netcoreapp is still in there, so it can light up the use of the IsSZArray property if that becomes available with a later change.

JonHanna added a commit to JonHanna/corefx that referenced this pull request Apr 6, 2017
stephentoub pushed a commit that referenced this pull request Apr 6, 2017
@JonHanna
Copy link
Contributor Author

JonHanna commented Apr 6, 2017

Test Innerloop OSX10.12 Debug x64 Build and Test please

Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@VSadov VSadov merged commit 06f5653 into dotnet:master Apr 6, 2017
@JonHanna JonHanna deleted the dynamic_arrays branch April 6, 2017 20:09
@safern
Copy link
Member

safern commented Apr 6, 2017

Hey @JonHanna looks like the test SingleRankNonSZArrayIndexed test that you added here is failing on Desktop. Is this a netcoreapp specific test? Difference in behavior?

Microsoft.CSharp.RuntimeBinder.Tests.ArrayHandling.SingleRankNonSZArrayIndexed [FAIL]
        System.Security.VerificationException : Operation could destabilize the runtime.
        Stack Trace:
             at CallSite.Target(Closure , CallSite , Object , Int32 , Int32 )
             at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
          D:\repos\corefx\src\Microsoft.CSharp\tests\ArrayHandling.cs(28,0): at Microsoft.CSharp.RuntimeBinder.Tests.ArrayHandling.SingleRankNonSZArrayIndexed()

Would you mind in fixing it?

You can repro by running:

build.cmd -framework:netfx
msbuild src\Microsoft.CSharp\tests\Microsoft.CSharp.Tests.csproj /t:rebuildandtest /p:TargetGroup=netfx

@JonHanna
Copy link
Contributor Author

JonHanna commented Apr 6, 2017

Sure. I'm on phone right now, but should be able to get to my computer within the hour.

@safern
Copy link
Member

safern commented Apr 6, 2017

Sure. I'm on phone right now, but should be able to get to my computer within the hour.

Sounds good. Thanks

@karelz karelz modified the milestone: 2.0.0 Apr 8, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Fix two array-related bugs in Microsoft.CSharp

Commit migrated from dotnet/corefx@06f5653
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants