Skip to content

Unhandled exception thrown if property has type of ref T #70

@Akarinnnnn

Description

@Akarinnnnn

I made a specialized collection for mutable large structs. To mutate a struct member by this indexer, it returns a reference. While analyzer processing this file, it thrown an exception and stopped generation.

Here is the repro code snippet:

	public struct ListStruct<T> : IEnumerable<T> where T : unmanaged
	{
		internal int CountInternal;
		private T[] _storage;

		// ...

		public readonly ref T this[int index]
		{
			[method: MethodImpl(MethodImplOptions.AggressiveInlining)]
			get => ref _storage[index];
		}

		// ...

And here is the stack trace:

System.Collections.Generic.KeyNotFoundException: Could not resolve a display name for ref T
at LivingDocumentation.SemanticModelExtensions.GetTypeDisplayString(SemanticModel semanticModel, ExpressionSyntax expression) in /_/src/LivingDocumentation.Analyzer/Extensions/SemanticModelExtensions.cs:line 24
at LivingDocumentation.SourceAnalyzer.VisitPropertyDeclaration(PropertyDeclarationSyntax node) in /_/src/LivingDocumentation.Analyzer/Analyzers/SourceAnalyzer.cs:line 158
at Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax.Accept(CSharpSyntaxVisitor visitor)
...

Hope these information will help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions