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

Unhandled exception. System.InvalidOperationException: Sequence contains no elements #167

Open
lufinkey opened this issue Nov 4, 2024 · 6 comments

Comments

@lufinkey
Copy link

lufinkey commented Nov 4, 2024

When trying to generate documentation using the dotnet tool, I get this error.

Config:

{
	"GeneratedPages": "Namespaces,Types",
	"AssemblyFilePath": "./Temp/bin/Debug/MegaParticle.Utils.dll",
	"ProjectDirectoryPath": "../../",
	"DocumentationFilePath": "./Temp/bin/Debug/MegaParticle.Utils.xml",
	"OutputDirectoryPath": "../../Documentation~",
	"Markdown.NestedTypeVisibilities": "DeclaringType"
}

Full stack trace:

At D:\Code\PokerVRLD\Modules\MegaParticle.Utils\Samples~\ExampleProject\RebuildDocumentation.ps1:3 char:1
+ defaultdocumentation --ConfigurationFilePath $configPath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Unhandled excep...ins no elements:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at DefaultDocumentation.Internal.DocItemReader.<.ctor>g__IsGenerated|5_0(IEntity entity, <>c__DisplayClass5_0& ) in 
D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 35
   at DefaultDocumentation.Internal.DocItemReader..ctor(Settings settings) in 
D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 157
   at DefaultDocumentation.Internal.DocItemReader.GetItems(Settings settings) in 
D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 354
   at DefaultDocumentation.Generator..ctor(Target loggerTarget, IRawSettings settings) in 
D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 116
   at DefaultDocumentation.Generator.Execute(Target loggerTarget, IRawSettings settings) in 
D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 195
   at DefaultDocumentation.Program.<>c.<Main>b__0_1(SettingsArgs a) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 24
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at DefaultDocumentation.Program.Main(String[] args) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 18
@Doraku
Copy link
Owner

Doraku commented Nov 6, 2024

latest beta version (1.0.0-beta04) should fix the error by ignoring the member but I'm curious why the the type is missing. Is it a private project or is it possible to know the member it fails for? You can set the log level to Debug.

@lufinkey
Copy link
Author

lufinkey commented Nov 7, 2024

Here's the logs with LogLevel Debug

2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.rectTransform": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.aspectMode"
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.aspectMode": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.aspectRatio"
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.aspectRatio": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.aspectControlsMinSize"
defaultdocumentation : Unhandled exception. System.InvalidOperationException: Sequence contains no elements
At D:\Code\PokerVRLD\Modules\MegaParticle.Utils\Samples~\ExampleProject\RebuildDocumentation.ps1:3 char:1
+ defaultdocumentation --ConfigurationFilePath $configPath --LogLevel D ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Unhandled excep...ins no elements:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at DefaultDocumentation.Internal.DocItemReader.<.ctor>g__IsGenerated|5_0(IEntity entity, <>c__DisplayClass5_0& ) in 
D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 35
   at DefaultDocumentation.Internal.DocItemReader..ctor(Settings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 
157
   at DefaultDocumentation.Internal.DocItemReader.GetItems(Settings settings) in 
D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Internal\DocItemReader.cs:line 354
   at DefaultDocumentation.Generator..ctor(Target loggerTarget, IRawSettings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 
116
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.aspectControlsMinSize": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.aspectControlsPreferredSize"
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.aspectControlsPreferredSize": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.flexibleWidth"
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.flexibleWidth": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.flexibleHeight"
   at DefaultDocumentation.Generator.Execute(Target loggerTarget, IRawSettings settings) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Common\Generator.cs:line 
195
   at DefaultDocumentation.Program.<>c.<Main>b__0_1(SettingsArgs a) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 24
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at DefaultDocumentation.Program.Main(String[] args) in D:\a\DefaultDocumentation\DefaultDocumentation\source\DefaultDocumentation.Console\Program.cs:line 18
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.flexibleHeight": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.layoutPriority"
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.layoutPriority": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.minWidth"
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.minWidth": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.minHeight"
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.minHeight": no documentation
2024-11-07 14:49:26.0804|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.preferredWidth"
2024-11-07 14:49:26.1186|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.preferredWidth": no documentation
2024-11-07 14:49:26.1186|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.preferredHeight"
2024-11-07 14:49:26.1186|DEBUG|DefaultDocumentation|Skipping documentation for member "MegaParticle.Utils.AspectRatioLayoutElement.preferredHeight": no documentation
2024-11-07 14:49:26.1186|DEBUG|DefaultDocumentation|handling member "MegaParticle.Utils.AspectRatioLayoutElement.UnityEngine.UI.ILayoutElement.flexibleWidth"

And here's a snippet from the class:

/// <summary>
/// A layout element that sets the minimum/preferred width/height based on an aspect ratio
/// </summary>
[RequireComponent(typeof(RectTransform))]
public class AspectRatioLayoutElement: UIBehaviour, ILayoutElement {
	public enum AspectMode {
		None,
		WidthControlsHeight,
		HeightControlsWidth
	}

	public RectTransform rectTransform => (this.transform as RectTransform);

	public AspectMode aspectMode {
		get => _aspectMode;
		set => _aspectMode = value;
	}
	[SerializeField]
	private AspectMode _aspectMode = AspectMode.None;

	public float aspectRatio {
		get => _aspectRatio;
		set => _aspectRatio = value;
	}
	[SerializeField]
	private float _aspectRatio = 1.0f;

	public bool aspectControlsMinSize {
		get => _aspectControlsMinSize;
		set => _aspectControlsMinSize = value;
	}
	[SerializeField]
	private bool _aspectControlsMinSize = false;

	public bool aspectControlsPreferredSize {
		get => _aspectControlsPreferredSize;
		set => _aspectControlsPreferredSize = value;
	}
	[SerializeField]
	private bool _aspectControlsPreferredSize = true;

	public float? flexibleWidth {
		get => _flexibleWidth;
		set => _flexibleWidth = value;
	}
	[SerializeField]
	private NullableValue<float> _flexibleWidth = null;

	public float? flexibleHeight {
		get => _flexibleHeight;
		set => _flexibleHeight = value;
	}
	[SerializeField]
	private NullableValue<float> _flexibleHeight = null;

	public int layoutPriority {
		get => _layoutPriority;
		set => _layoutPriority = value;
	}
	[SerializeField]
	private int _layoutPriority = 1;

	private Vector2? _lastRectSize = null;
	
	// methods were defined here
}

@lufinkey
Copy link
Author

lufinkey commented Nov 7, 2024

Also I tested 1.0.0-beta04 and it seems to be fixed. Thanks!

@Doraku
Copy link
Owner

Doraku commented Nov 7, 2024

The ILayoutElement is a unity interface I guess 🤔 ? Is it a unity package built by unity itself or are you referencing UnityEngine.UI manually so you can compile/generate the documentation outside of unity?

@lufinkey
Copy link
Author

Sorry missed this notification. This is code for a unity project, and yea ILayoutElement is an interface provided by unity. I'm using this in the visual studio project that gets generated by unity.

@Doraku
Copy link
Owner

Doraku commented Nov 19, 2024

I'll see if I can replicate this issue and understand why the unity dll is not loaded in DefaultDocumentation to access its metadata, I know they are regenerating the csproj and managing the references a little different 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants