Entitas icon indicating copy to clipboard operation
Entitas copied to clipboard

Roslyn: Sequence contains more than one element

Open optimisez opened this issue 7 years ago • 5 comments

@sschmid when u make the following careless mistake, it will unable to gen code even after u fix to correct attribute. Perhaps the better solution will be not to gen duplicate same piece of code when making careless mistake.

To reproduce:

  1. Put 2 same Event(true, EventType.Added)
[Unique, Game, Event(true, EventType.Added), Event(true, EventType.Added)]
public sealed class PauseComponent : IComponent 
{
}
  1. Gen code
  2. Changed one of it to Event(true, EventType.Removed)
  3. Gen code again
  4. Failed to gen code and pop up Sequence contains more than one element error

image

optimisez avatar Mar 15 '18 17:03 optimisez

Are you using jenny and the roslyn code generator? If so, please try deleting the generated folder and generate again.

sschmid avatar Mar 02 '19 10:03 sschmid

I just got this isssue too after renaming a component. Now I can't build at all. Even deleting Generated folder doesn't work.

akoolenbourke avatar Apr 09 '19 21:04 akoolenbourke

Renaming will not break it. After deleting the generated folder, you still get the error? Can you do gen -v to see where it breaks?

sschmid avatar Apr 09 '19 21:04 sschmid

Hi Simon, I found the error. It was my fault but maybe this situation could be reported better.

I copied a component file (Let's call it AComponent) and thought I had renamed the file and class to BComponent - I hadn't. AComponent had a Cleanup(CleanupMode.DestroyEntity) on it and therefore so did the duplicated component (With the same name). When I generated I got the error and it wasn't until I removed the Cleanup..... code from AComponent that I could build. Once I found the rename problem I renamed the duplicate to its new name and things could go back to normal(I could re-add the Cleanup)

System.InvalidOperationException: Sequence contains more than one element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider.<>c.<GetData>b__19_2(INamedTypeSymbol type)
   at System.Linq.Enumerable.<>c__DisplayClass6_0`1.<CombinePredicates>b__0(TSource x)
   at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider.GetData()
   at DesperateDevs.CodeGeneration.CodeGenerator.CodeGenerator.generate(String messagePrefix, IPreProcessor[] preProcessors, IDataProvider[] dataProviders, ICodeGenerator[] codeGenerators, IPostProcessor[] postProcessors)
   at DesperateDevs.CodeGeneration.CodeGenerator.CodeGenerator.DryRun()
   at DesperateDevs.CodeGeneration.CodeGenerator.CLI.DoctorCommand.run()
   at DesperateDevs.CLI.Utils.AbstractCommand.Run(CLIProgram program, String[] args)
   at DesperateDevs.Serialization.CLI.Utils.AbstractPreferencesCommand.Run(CLIProgram program, String[] args)
   at DesperateDevs.CLI.Utils.CLIProgram.runCommand(String[] args)

akoolenbourke avatar Apr 09 '19 21:04 akoolenbourke

I'll see if I can provide better error messages!

sschmid avatar Sep 08 '22 21:09 sschmid