Version 3: When Equals assembly is unused build fails with an exception
BrunoJuchli opened this issue · comments
When performing a build immediately after adding Equals.Fody 3.0.1 to a project, the build fails with:
Error: Fody: An unhandled exception occurred:
Exception:
Failed to execute weaver C:\Users\BRUNO.lorenz.juchli.nuget\packages\equals.fody\3.0.1\build..\weaver\Equals.Fody.dll
Type:
System.Exception
StackTrace:
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 189
at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 108
Source:
FodyIsolated
TargetSite:
Void ExecuteWeavers()
Sequence contains no matching element
Type:
System.InvalidOperationException
StackTrace:
at System.Linq.Enumerable.Single[TSource](IEnumerable1 source, Func
2 predicate)
at ModuleWeaver.FindReferences(Func2 typeFinder) at ModuleWeaver.Execute() at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 181 Source: System.Core TargetSite: TSource Single[TSource](System.Collections.Generic.IEnumerable
1[TSource], System.Func`2[TSource,System.Boolean])
The exception occurs when trying to resolve the [assembly reference to "Equals"}(https://github.com/Fody/Equals/blob/master/Equals.Fody/ReferenceFinder.cs#L53).
Minimal Repro
See #104.
Alternatively:
- Create new Project
- Add Fody
- Add Equals.Fody
- Build
Workaround
- put an
[Equals]
attribute on a type - remove Equals.Fody from the project as long as you don't use it (don't forget to adapt FodyWeavers.xml accordingly, too)