Open MovGP0 opened 9 years ago
Are you using NameOf.Fody 0.8? I just tested this and it compiles and writes "Property" to the console at run-time.
yes. I was using the version 0.8. strangely, I was able to compile one project, while a colleague of mine got the error. so I made a test project and got the same error.
also, non-static classes/properties seem to work. the issue is with static classes only.
What version of VS are you using and what version of .NET are you targeting? If you can link me to your solution which is giving the error, I can check it out.
I was able to replicate the error on VS 2012/.NET 4.0 and 2013/.NET 4.5; haven't tried 2015/.NET4.6 yet.
Might provide an example solution later today.
The interesting thing is, that when I have a successful build and then change the code like the one above, it works. After cleaning or rebuilding it causes the above error.
The solution is here https://github.com/MovGP0/NameOfTest
Confirmed the failure of your solution, modified to the code above, on my machine. I suspect a race condition. I'll check tonight. Thanks again for your help and patience!
I reworked a few things and published a 0.8.2 NuGet package. I refactored the opcode groupings to prevent potential static initialization order bugs (I don't think this was happening, but it is safer now anyway), and I refactored a few things in the weaving code to avoid throwing NullReferenceException.
Is your issue resolved? Can I close this?
Unfortunately, this problem is still occuring on a different place now:
Error 757 Fody: An unhandled exception occurred:
Exception:
Object reference not set to an instance of an object.
StackTrace:
at NameOf.Fody.ModuleWeaver.<IsNotUsed>b__7(MethodDefinition x) in c:\Users\nick.strupat\Documents\Visual Studio 2013\Projects\NameOf\NameOf.Fody\ModuleWeaver.cs:line 47
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at NameOf.Fody.ModuleWeaver.IsNotUsed(IMetadataTokenProvider methodDefinition) in c:\Users\nick.strupat\Documents\Visual Studio 2013\Projects\NameOf\NameOf.Fody\ModuleWeaver.cs:line 45
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at NameOf.Fody.ModuleWeaver.Execute() in c:\Users\nick.strupat\Documents\Visual Studio 2013\Projects\NameOf\NameOf.Fody\ModuleWeaver.cs:line 33
at lambda_method(Closure , Object )
at InnerWeaver.ExecuteWeavers() in c:\ConsoleBuildAgent\work\ed448661dbb30d2e\FodyIsolated\InnerWeaver.cs:line 144
at InnerWeaver.Execute() in c:\ConsoleBuildAgent\work\ed448661dbb30d2e\FodyIsolated\InnerWeaver.cs:line 62
Source:
NameOf.Fody
TargetSite:
System.Collections.Generic.IEnumerable`1[Mono.Cecil.Cil.Instruction] <IsNotUsed>b__7(Mono.Cecil.MethodDefinition)
I have the following code:
I get the following build Error: