Spring.NET
  1. Spring.NET
  2. SPRNET-1467

AbstractProxyMethodBuilder don't set generic argument type on method constraint

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.3.2
    • Fix Version/s: 2.0
    • Labels:
      None

      Description

      You have a class with a method with a constraint based on a generic argument of the class.
      Create a proxy for a object of that class.
      The method on the created proxy got a wrong constraint, once it doens't replace the generic argument on the constraint.

      Very simple example:
      public class ClassA<Z>
      {
      public virtual void DoSomething<T>() where T : Z { }
      }

      When you create a proxy for a object of type ClassA<string>, the proxy should have the method:
      public virtual void DoSomething<T>() where T : string { }

      But when the method is generated on the proxy the T : Z constraint isn't replaced by T : string.

      So I get the following error:
      System.TypeLoadException: Method 'DoSomething' on type 'DecoratorAopProxy_d4dcef2d192d458d9d5ca99705122487' from assembly 'Spring.Proxy, Version=0.0.0.0, Culture=neutral, PublicKeyToken=65e474d141e25e07' tried to implicitly override a method with weaker type parameter constraints.

      I'm attaching a Test class that reproduce the error and a possible solution for the problem.

      1. Spring.NET proxy constraint fix.txt
        5 kB
        Lucas Lorentz
      2. SpringProxyTest.cs
        2 kB
        Lucas Lorentz

        Activity

        Hide
        Steve Bohlen added a comment -

        Thanks for reporting this (and for the suggested fix); we'll look into this for the 2.0M1 release.

        Show
        Steve Bohlen added a comment - Thanks for reporting this (and for the suggested fix); we'll look into this for the 2.0M1 release.

          People

          • Assignee:
            Bruno Baia
            Reporter:
            Lucas Lorentz
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: