IntroduceInterface causes NullReferenceException crash when interface contains default values

amiy's Avatar

amiy

19 Dec, 2017 08:59 AM

When I create an interface with a method containing default argument values, and I use the InstanceLevelAspect to IntroduceInterface it, the compiler fails do to null reference exception.

Code like this:
   [IntroduceInterface(typeof(ITester))]
    [Serializable]
    public class TestAttribute : InstanceLevelAspect, ITester
   {...}

    public interface ITester
    {
        void Run(string value = "");
    }

Exception is:

Severity Code Description Project File Line Suppression State
Error Unhandled exception (4.3.21.0, postsharp-net40-x64-srv.exe, CLR 4.0.30319.394271, Release): System.NullReferenceException: Object reference not set to an instance of an object.
   at PostSharp.Sdk.Buffers.BufferWriter.WriteRawString(String s, Encoding encoding)
   at ^/vWxD3eYDOIx.^wdkNIZCy[??0](^/fRRnkiTvxqu _0, ??0 _1, ^EyL1LQX01Ck8 _2, ^0RC0kpHqS6Uy _3, Dictionary`2 _4, Int32 _5, Int32 _6)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteConstant(SerializedValue _0, MetadataToken _1, ITypeSignature _2)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteParameter(ParameterDeclaration _0)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteMethodDef(MethodDefDeclaration _0, MetadataToken _1)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteTypeDef(TypeDefDeclaration _0, MetadataToken _1)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteTypeDefs()
   at PostSharp.Sdk.Binary.ModuleWriter.Prepare()
   at ^Up6wxUIUnN6a.^VfvrABjR()
   at ^Up6wxUIUnN6a.^SkiT()
   at ^Up6wxUIUnN6a.^8KD6D2SV(String _0)
   at ^cyC/TYSlPGB/.^wvPm(^RtksFin57NJ8 _0, ^8gP93Xsl\+Imn _1)
   at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
   at PostSharp.Sdk.Extensibility.Project.Execute()
   at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
   at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation). PostSharpTests ***Documents\Visual Studio 2015\Projects\Experiments15\PostSharpTests\POSTSHARP

  1. Support Staff 1 Posted by PostSharp Techn... on 19 Dec, 2017 02:35 PM

    PostSharp Technologies's Avatar

    Hello,

    thanks for reporting the issue, we will be working on a fix.

    (internal issue #15753)

    All the best,
    Daniel

  2. Support Staff 2 Posted by PostSharp Techn... on 03 Jan, 2018 01:18 PM

    PostSharp Technologies's Avatar

    Hello,

    We're closing the ticket for now as the bug has been internally filed as issue #15753. We will contact you as soon as the bug fix has been released.

    For more details on our support policies and prioritization of bug fixes, please visit https://www.postsharp.net/support/policies

    Thanks,
    PostSharp Team

  3. PostSharp Technologies closed this discussion on 03 Jan, 2018 01:18 PM.

  4. PostSharp Technologies re-opened this discussion on 27 Jan, 2018 08:04 PM

  5. Support Staff 3 Posted by PostSharp Techn... on 27 Jan, 2018 08:04 PM

    PostSharp Technologies's Avatar

    Hello,

    the bug #15753 has been fixed in the current release of PostSharp 5.0.44.
    Should you need further help with this issue, don't hesitate to re-open this discussion.

    -alex

  6. PostSharp Technologies closed this discussion on 27 Jan, 2018 08:04 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac