Bug 27143 - Extensions methods are not recognized without the 'this' modifier only in a Unified API app
Summary: Extensions methods are not recognized without the 'this' modifier only in a U...
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.6.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-17 09:18 UTC by John Miller [MSFT]
Modified: 2015-02-17 09:55 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Case (17.50 KB, application/zip)
2015-02-17 09:18 UTC, John Miller [MSFT]
Details


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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description John Miller [MSFT] 2015-02-17 09:18:58 UTC
Created attachment 9878 [details]
Test Case

**Overview:**

   When using the Unified API, extensions methods are not recognized unless qualified with the "this" keyword. 

**Steps to Reproduce:**

   1. Try to build the attached TextTest project (Unified API app)

**Actual Results:**

   The extension method EndEditing for UITextField is not recognized. See screenshot:http://screencast.com/t/zBGApahG

**Expected Results:**

   The method should be recognized and not require the "this" keyword. 

**Build Date & Platform:**

   XI 8.6.1.20
   Mono 3.12

**Additional Information:**

   There is a Classic API project in the solution to show this is not an issue when using the Classic API. 
   Workaround: use the "this" keyword
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-02-17 09:55:08 UTC
This is just how C# works, extension methods can only be invoked using an instance expression (the implicit 'this' inside instance methods is not enough) [1]

This is a deliberate API difference between Classic and Unified.

[1] https://msdn.microsoft.com/en-us/library/bb308966.aspx#csharp3.0overview_topic6