3

Issue has been fixed in PostSharp 4.3.27

Given the following code in C#

 var obj = new
 {
     p0 = 0,
     p1 = 1
     p2 = 2,
     // and so on until 127 ...
     p127 = 127
 }

I get this error trying to build the project with PostSharp enabled:

Severity Code Description Project File Line Suppression State
Error error:
Unhandled exception (4.3.25.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.394802, Release): The file c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\obj\Debug\Before-PostSharp\PostSharpTest.exe is not a valid .NET assembly. See below for details. PostSharpTest c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\POSTSHARP
Error System.BadImageFormatException: The file c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\obj\Debug\Before-PostSharp\PostSharpTest.exe is not a valid .NET assembly. ---> PostSharp.Sdk.AssertionFailedException: Invalid value 128 for enumeration ^Bw+U+DEY6J8e at location element type in type signature. at PostSharp.Sdk.Binary.ModuleReader.ReadTypeSignature(BufferReader& _0) at PostSharp.Sdk.Binary.ModuleReader.ReadTypeSignature(BufferReader& _0) at PostSharp.Sdk.Binary.ModuleReader.ImportTypeSpec(Int32 _0) at PostSharp.Sdk.Binary.ModuleReader.ImportTypeSpecs() at PostSharp.Sdk.Binary.ModuleReader.ReadModule() at PostSharp.Sdk.Binary.ModuleReader.ReadModule() at PostSharp.Sdk.Binary.ModuleReader.ReadModule(ReadModuleStrategy _0) at PostSharp.Sdk.CodeModel.Domain.LoadAssembly(String assemblyLocation, LoadAssemblyOptions options) at PostSharp.Sdk.Extensibility.ModuleLoadDirectFromFileStrategy.Load(Domain domain) at PostSharp.Sdk.Extensibility.Project.^LvMUl75+(ModuleLoadStrategy _0) at PostSharp.Sdk.Extensibility.Project.^63o9P8x3(ModuleDeclaration _0, ModuleLoadStrategy _1, Domain _2, ProjectInvocationParameters _3, Boolean _4) at PostSharp.Sdk.Extensibility.Project.CreateInstance(Domain domain, ProjectInvocation projectInvocation, Boolean reuseDomain) at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation) at PostSharp.Hosting.Program.ExecuteImpl() PostSharpTest c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\POSTSHARP

The message

Invalid value 128 for enumeration ^Bw+U+DEY6J8e at location element type in type signature.

Seems to be of some significance but I'm not familiar with PostSharp internals.

Removing p127 works fine. Has anyone else encountered this limitation?

John Merchant
  • 215
  • 1
  • 3
  • 10
  • 1
    OK, if nobody's going to state the bleedingly obvious, I will: in what bizarre code base is this an actual problem? Having any type with 128 properties is crazy enough, but making it an anonymous type is just extra nuts on the side. Is this generated code that you then run PostSharp over? How about using a dictionary instead? Even if PostSharp fixes this limitation, you're likely to encounter more problems with such huge property bags -- efficiently enumerating over them is not going to be a picknick either. – Jeroen Mostert Dec 24 '16 at 16:25
  • 2
    Thanks for reporting this issue. PostSharp team investigates it and we'll get back to you once we have more info. – AlexD Dec 25 '16 at 22:38
  • @JeroenMostert I work on enterprise software and use the Dapper library in the database layer. It uses anonymous types to specify sql parameters. – John Merchant Dec 26 '16 at 02:42
  • If your sproc takes 128 or more parameters (the limit being 2100), a table-valued parameter is worth looking into. Also, unless somebody is manually typing out 128 parameters (improbable) using Dapper really doesn't gain you anything here -- you may as well construct a `DbCommand` the old-fashioned way. That said, if your software is sufficiently enterprisey, I realize these may not be options (and of course there's no reason PostSharp shouldn't be able to handle it). – Jeroen Mostert Dec 26 '16 at 09:56
  • 1
    This bug is fixed in PostSharp 4.3.27. – Jakub Linhart Jan 30 '17 at 17:02

2 Answers2

1

This was fixed in PostSharp 4.3.27

John Merchant
  • 215
  • 1
  • 3
  • 10
-1

MulticastTargets Enumeration

Kinds of targets to which multicast custom attributes (MulticastAttribute) can apply.

So for InstanceConstructor max value is 128

Taken from here.

Taras M.
  • 1
  • 1