mikhailshilkov / With.Fody

A Fody addin to extend immutable C# classes with With() methods to return a copy of an object with one property modified.
MIT License
36 stars 3 forks source link

Support for inheritance with assembly references #8

Closed aalmada closed 7 years ago

aalmada commented 7 years ago

This is my attempt to add support for inheritance with classes in different assemblies but in the same folder. This would be the most common scenario. Added assembly resolvers in weaver and in the tests but the module is still not saving successfully. @mikhailshilkov Do you experience with assembly/type resolution in Cecil?

mikhailshilkov commented 7 years ago

I was naughty and renamed projects and classes in #7. Could you re-apply your changes on master?

aalmada commented 7 years ago

No problem. I like the new names.

aalmada commented 7 years ago

@mikhailshilkov I fixed the build but please don't merge yet. It's still not working.

aalmada commented 7 years ago

@mikhailshilkov Passing all tests. I'd like to test it a real project build. How do you do it?

mikhailshilkov commented 7 years ago

You can build a package with a new version, make a local NuGet feed (from local folder) and put the package there. Or just hack-copy the dll to your packages folder and rebuild.

aalmada commented 7 years ago

Looks like the referenced type is not resolved correctly. :(

2>MSBUILD : error : Fody: An unhandled exception occurred: 2>MSBUILD : error : Exception: 2>MSBUILD : error : Value cannot be null. 2>MSBUILD : error : Parameter name: type 2>MSBUILD : error : StackTrace: 2>MSBUILD : error : at Mono.Cecil.ModuleDefinition.ImportReference(TypeReference type, IGenericParameterProvider context) 2>MSBUILD : error : at Mono.Cecil.ModuleDefinition.ImportReference(TypeReference type) 2>MSBUILD : error : at ModuleWeaver.GetAllProperties(TypeReference type) 2>MSBUILD : error : at ModuleWeaver.GetAllProperties(TypeDefinition type) 2>MSBUILD : error : at ModuleWeaver.GetAllProperties(TypeReference type) 2>MSBUILD : error : at ModuleWeaver.GetAllProperties(TypeDefinition type) 2>MSBUILD : error : at ModuleWeaver.<>cDisplayClass19_0.b1(ParameterDefinition par) 2>MSBUILD : error : at System.Linq.Enumerable.All[TSource](IEnumerable1 source, Func2 predicate) 2>MSBUILD : error : at ModuleWeaver.<>cDisplayClass19_0.b0(MethodDefinition ctor) 2>MSBUILD : error : at System.Linq.Enumerable.<>c__DisplayClass6_01.<CombinePredicates>b__0(TSource x) 2>MSBUILD : error : at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() 2>MSBUILD : error : at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable1 source, TAccumulate seed, Func3 func) 2>MSBUILD : error : at ModuleWeaver.GetValidConstructor(TypeDefinition type) 2>MSBUILD : error : at ModuleWeaver.Execute() 2>MSBUILD : error : at lambda_method(Closure , Object ) 2>MSBUILD : error : at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 161 2>MSBUILD : error : at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 82 2>MSBUILD : error : Source: 2>MSBUILD : error : Mono.Cecil 2>MSBUILD : error : TargetSite: 2>MSBUILD : error : Mono.Cecil.TypeReference ImportReference(Mono.Cecil.TypeReference, Mono.Cecil.IGenericParameterProvider) 2>MSBUILD : error :

aalmada commented 7 years ago

The exception happens if the referenced assembly is a PCL :o

aalmada commented 7 years ago

@mikhailshilkov Everything's working! Looks like Cecil only supports PCL Profile433.

aalmada commented 7 years ago

@mikhailshilkov Tested now on my work project and it does work on a multi-assembly build.

mikhailshilkov commented 7 years ago

I don't have this case in my projects... Time to integrate?

aalmada commented 7 years ago

@mikhailshilkov Unless you have comments about the code