Skip to content

Improperly throws System.TypeLoadException on mock when a record has a base record on dotnet 6 #1273

@tgrieger-sf

Description

@tgrieger-sf

A System.TypeLoadException is incorrectly thrown on dotnet 6 when mocking a record with a base record. See simple repro below.

using System;
using Moq;

namespace Testing
{
	public record First : Base
	{
		public virtual string Something { get; init; }
	}

	public record Base {}

	class Program
	{
		static void Main(string[] args)
		{
			Mock<First> mockFirst = new();
			mockFirst.SetupGet(f => f.Something).Returns("string");
			Console.WriteLine(mockFirst.Object.Something);
		}
	}
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions