Bug 58455 - Non-invocable member cannot be used like a method.
Summary: Non-invocable member cannot be used like a method.
Alias: None
Product: Class Libraries
Classification: Mono
Component: Microsoft.CSharp ()
Version: 5.2 (2017-04)
Hardware: PC All
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
Depends on:
Reported: 2017-07-28 12:35 UTC by Dawid Wojciechowski
Modified: 2017-09-07 10:00 UTC (History)
4 users (show)

Is this bug a regression?: Yes
Last known good build:

Csproj file. (1.79 KB, application/x-csproj)
2017-07-28 12:35 UTC, Dawid Wojciechowski
Test program (405 bytes, text/x-csharp)
2017-07-28 12:35 UTC, Dawid Wojciechowski
packages.config with Dynamitey (136 bytes, application/octet-stream)
2017-07-28 12:35 UTC, Dawid Wojciechowski

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 58455 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Dawid Wojciechowski 2017-07-28 12:35:03 UTC
Created attachment 23873 [details]
Csproj file.

We're using the Dynamitey library to access properties from types.

On mono >= 5.2 this simple test case fails.

It works well on .NET and on Mono and older.

The failing test tries to call a getter from a static property.
A similar reflection-based call would look like:

value = desiredProperty.GetGetMethod().Invoke(null, Type.EmptyTypes);

Unfortunately we were not able to reproduce the problem without using the library.

Steps to reproduce the problem:
1. nuget restore -PackagesDirectory . packages.config 
2. xbuild MonoBug.csproj
3. mono bin/Debug/MonoBug.exe

Expected results:
"Test" should be displayed.

Actual results:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Non-invocable member 'MonoBug.TestClass.GetProp' cannot be used like a method.
  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object)
  at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet] (System.Runtime.CompilerServices.CallSite site, T0 arg0) [0x00104] in <a86c0cf33dc14737a92c0e6a220c83ee>:0 
  at Dynamitey.Internal.Optimization.InvokeHelper.InvokeGetCallSite (System.Object target, System.String name, System.Type context, System.Boolean staticContext, System.Runtime.CompilerServices.CallSite& callsite) [0x000d4] in <b36ca8e08a2f4120a70f2b4d5ba13455>:0 
  at Dynamitey.Dynamic.InvokeGet (System.Object target, System.String name) [0x0000e] in <b36ca8e08a2f4120a70f2b4d5ba13455>:0 
  at MonoBug.MainClass.Main (System.String[] args) [0x00015] in <31b5a7d73a3c465eb265c6c215598255>:0
Comment 1 Dawid Wojciechowski 2017-07-28 12:35:34 UTC
Created attachment 23874 [details]
Test program
Comment 2 Dawid Wojciechowski 2017-07-28 12:35:57 UTC
Created attachment 23875 [details]
packages.config with Dynamitey