Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fody error when attempting to use source generation path #3372

Closed
peppy opened this issue Jul 7, 2023 · 1 comment
Closed

Fody error when attempting to use source generation path #3372

peppy opened this issue Jul 7, 2023 · 1 comment

Comments

@peppy
Copy link

peppy commented Jul 7, 2023

What happened?

I recently realised we never finished migrating to the source generation path, so I'm attempting to fix the remaining issues.

We're currently seeing a mysterious message coming from Fody.

The branch with required changes to make source gen work: https://github.com/ppy/osu/compare/master...peppy:osu:realm-source-gen-v2?expand=1

Repro steps

Attempt to build

Version

11.1.2

What Atlas Services are you using?

Local Database only

What type of application is this?

Other

Client OS and version

macOS

Code snippets

No response

Stacktrace of the exception/crash you're getting

osu.Game
  Fody/Realm: An unexpected error occurred while weaving 'BeatmapCollection': Specified argument was out of the range of valid values..
Callstack:
   at Mono.Collections.Generic.Collection`1.RemoveAt(Int32 index) in C:\projects\fody\cecil\Mono.Collections.Generic\Collection.cs:line 159
   at RealmWeaver.Weaver.RemoveBackingFields(TypeDefinition type, HashSet`1 backingFields)
   at RealmWeaver.Weaver.WeaveGeneratedType(TypeDefinition type)
   at RealmWeaver.Weaver.<Execute>b__39_1(MatchingType matchingType)
  Fody: An unhandled exception occurred:
Exception:
Member 'System.String <Name>k__BackingField' is declared in another module and needs to be imported
Type:
System.ArgumentException
StackTrace:
   at Mono.Cecil.MetadataBuilder.LookupToken(IMetadataTokenProvider provider) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 2264
   at Mono.Cecil.Cil.CodeWriter.WriteOperand(Instruction instruction) in C:\projects\fody\cecil\Mono.Cecil.Cil\CodeWriter.cs:line 270
   at Mono.Cecil.Cil.CodeWriter.WriteInstructions() in C:\projects\fody\cecil\Mono.Cecil.Cil\CodeWriter.cs:line 180
   at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody(MethodDefinition method) in C:\projects\fody\cecil\Mono.Cecil.Cil\CodeWriter.cs:line 111
   at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method) in C:\projects\fody\cecil\Mono.Cecil.Cil\CodeWriter.cs:line 54
   at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 1675
   at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 1668
   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 1468
   at Mono.Cecil.MetadataBuilder.AddTypes() in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 1440
   at Mono.Cecil.MetadataBuilder.BuildTypes() in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 1289
   at Mono.Cecil.MetadataBuilder.BuildModule() in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 1059
   at Mono.Cecil.MetadataBuilder.BuildMetadata() in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 1029
   at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 147
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read) in C:\projects\fody\cecil\Mono.Cecil\ModuleDefinition.cs:line 971
   at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 146
   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 119
   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters) in C:\projects\fody\cecil\Mono.Cecil\AssemblyWriter.cs:line 78
   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters) in C:\projects\fody\cecil\Mono.Cecil\ModuleDefinition.cs:line 1160
   at InnerWeaver.WriteModule() in C:\projects\fody\FodyIsolated\ModuleWriter.cs:line 18
   at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 115
Source:
Mono.Cecil
TargetSite:
Mono.Cecil.MetadataToken LookupToken(Mono.Cecil.IMetadataTokenProvider)

Relevant log output

No response

@peppy
Copy link
Author

peppy commented Jul 7, 2023

Apologies, this is already covered by #3247. I somehow missed the reply in this thread 😓 .

@peppy peppy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants