Capgemini / Cauldron

C# Toolkit
MIT License
76 stars 18 forks source link

[Cauldron.Interception.Fody]Assembly wide AttributeDecorator build error #68

Closed wangyenan closed 5 years ago

wangyenan commented 5 years ago

Here's my demo.cauldron.fody.json file,I wrote it according to the demo,please see the bold line:

[ { // If true, the decorators decribed in decorator // are only applied if the constant "DEBUG" is set. // Default is false. "debug-only": false, // Activates / deactivates the decorators. // Default is true. "is-active": true, // A collection of decorators with its associated filter. "decorator": [ { // The full name of the attribute // The attribute itself has to reside in the referenced assemblies. "type-name": "MethodInterceptDemo.DemoInterceptorAttribute", // The parameters that is passed to the attibute. "parameters": [ "" ], // If true, classes are included in the search. Default is false. "decorate-class": true, // If true, methods are included in the search. Default is false. "decorate-methods": true, // If true, properties are included in the search. Default is false. "decorate-properties": false, // Specifies certain properties of the class for the filter. // This has no effect of decorate-class is false. "target-class-filter": { // Also include public classes. Default is true. "public": false, // Also include internal classes Default is true. "internal": true, // Also include private classes Default is true. "private": false, // Also include static classes Default is true. "static": false, // Also include instanced classes Default is true. "instanced": true, // The name of the class. // This accepts regex -> example: \wController will exclude all classes // with a name that does not end with Controller. // is equivalent to [a-zA-Z]. // Default is "" "name": "DemoClass", // Only includes classes that implements all listed interfaces. // Default is "no interface restrictions" "requires-interfaces": [ "" ] }, // Specifies certain properties of the method for the filter. "target-method-filter": { // Also include public methods. Default is true. "public": true, // Also include internal methods. Default is true. "internal": true, // Also include protected methods. Default is true. "protected": true, // Also include private methods. Default is true. "private": true, // Also include static methods. Default is true. "static": true, // Also include non-static methods. Default is true. "instanced": true, // The name of the method. // Accepts regex. // is equivalent to [a-zA-Z]. // Default is "" "name": "InvokeCreateConnection", // Only includes methods that returns the following type. // Default is empty. Empty means no return type filter. // To filter void methods, use System.Void. "return-types-name": "System.Void", // Only includes methods that matches the parameters list types. // Default is false. "parameter-match": false, // Only includes methods that strictly matches the parameter types. // Strict means that the type name has to exactly match; otherwise // the types are tested for assignability. Means if the parameter type // is System.Int32, then all methods with parameter type System.Int32 and // System.Object are included. // Default is false. "parameter-strict": false, // Only include methods that matches the listes parameter types. // Default is empty list which also means paramterless. "parameters": [ "" ] }, // Specifies certain properties of the property for the filter. "target-property-filter": { // Also include public properties. Default is true. "public": true, // Also include internal properties. Default is true. "internal": true, // Also include protected properties. Default is true. "protected": true, // Also include private properties. Default is true. "private": true, // Also include static properties. Default is true. "static": true, // Also include non-static properties. Default is true. "instanced": true, // The name of the property. // Accepts regex. // is equivalent to [a-zA-Z]. // Default is "". "name": "*", // Only includes properties with type name. // Default is empty. Empty means no return type filter. "return-types-name": "" } } ] } ]

When I build my project,follwing build error occurs: Error converting value "System.Void" to type 'System.String[]'

StackTrace: 1>MSBUILD : error : at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 208 1>MSBUILD : error : at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 103 1>MSBUILD : error : Source: 1>MSBUILD : error : FodyIsolated 1>MSBUILD : error : TargetSite: 1>MSBUILD : error : Void ExecuteWeavers() 1>MSBUILD : error : Error converting value "System.Void" to type 'System.String[]'. Path '[0].decorator[0].target-method-filter.return-types-name', line 69, position 44. 1>MSBUILD : error : Type: 1>MSBUILD : error : Newtonsoft.Json.JsonSerializationException

When I leave return-types-name as empty,for example: "return-types-name": ""

Then following build error occurs:Object reference not set to an instance of an object.

StackTrace: 1>MSBUILD : error : at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 208 1>MSBUILD : error : at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 103 1>MSBUILD : error : Source: 1>MSBUILD : error : FodyIsolated 1>MSBUILD : error : TargetSite: 1>MSBUILD : error : Void ExecuteWeavers() 1>MSBUILD : error : Object reference not set to an instance of an object. 1>MSBUILD : error : Type: 1>MSBUILD : error : System.NullReferenceException 1>MSBUILD : error : StackTrace: 1>MSBUILD : error : at Cauldron.Interception.Fody.ModuleWeaver.<>c__DisplayClass17_0.b__1(DecoratorDecriptionParameter x)

How can I set the value for "return-types-name" of the method filter,thanks a lot.

reflection-emit commented 5 years ago

Hi,

sorry for answering so late… I somehow missed the GitHub notification mail... Sorry for that... The json model requires an array... You have to write it this way:

"return-types-name": [ "System.Void" ],

I'll update the examples

wangyenan commented 5 years ago

Thanks a lot,I'll try it.