Skip to content

Nullable Type Breaks File Name #275

@JasonBock

Description

@JasonBock

Describe the bug
If the type given to any of the mock methods has a nullable type in it, the file name (hintName) has a ? in it, and it can't have that character. Probably just need to replace it with the word null.

Note: this will get fixed with #274.

To Reproduce

	public static async Task GenerateWhenNullableIsInTypeAsync()
	{
		var code =
			"""
			using Rocks;
			using System;

			#nullable enable

			public interface IType<T>
			{
				void Foo(T value);
			}

			public static class Test
			{
				public static void Generate()
				{
					var rock = Rock.Create<IType<int?>>();
				}
			}
			""";

	var generatedCode = // Gen'd code goes here.;

	await TestAssistants.RunAsync<RockCreateGenerator>(code,
		new[] { (typeof(RockCreateGenerator), "ITypeint?_Rock_Create.g.cs", generatedCode) },
		Enumerable.Empty<DiagnosticResult>()).ConfigureAwait(false);
}

Expected behavior
The test passes.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions