False error with extensions in partial classes

4 posts, 0 answers
  1. Zbynek
    Zbynek avatar
    2 posts
    Member since:
    Apr 2008

    Posted 09 Jun 2010 Link to this post

    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(); 
            } 
        } 
     





  2. Hans Kratz
    Admin
    Hans Kratz avatar
    102 posts

    Posted 10 Jun 2010 Link to this post

    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.
  3. DevCraft banner
  4. Zbynek
    Zbynek avatar
    2 posts
    Member since:
    Apr 2008

    Posted 10 Jun 2010 Link to this post

    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
  5. Hans Kratz
    Admin
    Hans Kratz avatar
    102 posts

    Posted 16 Jun 2010 Link to this post

    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.
Back to Top