This is a migrated thread and some comments may be shown as answers.

False error with extensions in partial classes

3 Answers 87 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zbynek
Top achievements
Rank 1
Zbynek asked on 09 Jun 2010, 11:13 PM
I have ran into false errors with extension method defined inside partial class.
I have attached test code to reproduce the issue. The problem is that second partial class is missing keyword "static". But the code get compiled just fine.

Edit:
The same also happend when one of those classes is missing "public" access modifier and the extension method is used in different assembly.

Zbynek

namespace TestProject 
    public static partial class Extensions 
    { 
        //... 
    } 
 
    partial class Extensions 
    { 
        public static void ExtentionMethod(this object obj) 
        { 
        } 
    } 
 
 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            object obj = new object(); 
            obj.ExtentionMethod(); 
        } 
    } 
 





3 Answers, 1 is accepted

Sort by
0
Hans Kratz
Telerik team
answered on 10 Jun 2010, 08:23 PM
Hello Zbynek,

thanks a lot for your feedback. Can you try with the new beta build (just released today). I could not reproduce the problem with that build so it seems fixed already.

Kind regards,
Hans Kratz
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Zbynek
Top achievements
Rank 1
answered on 10 Jun 2010, 08:54 PM
Hello Hans,
I have tested it with the new version and the result is that half of the problem is fixed.

The only remaining issue is when the extension method is defined inside partial class with missing "public" access modifier.
If you split the example into separate assemblies, one with extension definitions and another where is the extension used you'll get "Unknown method error" on ExtensionMethod call. When you add "public" to the second Extension class definition, the error disappear.

Kind regards

Zbynek
0
Hans Kratz
Telerik team
answered on 16 Jun 2010, 11:44 AM
Hi Zbynek,

thanks. I could reproduce this issue and added a new item to the issue tracker. You will be automatically notified once this issue is resolved.

I have added some Telerik points to your account to compensate you for your efforts.

Regards,
Hans Kratz
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Code Analysis
Asked by
Zbynek
Top achievements
Rank 1
Answers by
Hans Kratz
Telerik team
Zbynek
Top achievements
Rank 1
Share this question
or