Skip to content

Commit

Permalink
Fix/open generic typeof (#1532)
Browse files Browse the repository at this point in the history
* fixed a scenario where an open generic would not get the correct number of commas!

* Automatically linting code

---------

Co-authored-by: Rocket Understudy <[email protected]>
  • Loading branch information
david-driscoll and rsg-bot authored Apr 19, 2024
1 parent 3f4176a commit 18ff415
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Conventions.Analyzers/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static string GetGenericDisplayName(ISymbol? symbol)
if (namedTypeSymbol.IsOpenGenericType())
{
sb.Append('<');
for (var i = 1; i < namedTypeSymbol.Arity - 1; i++)
for (var i = 1; i < namedTypeSymbol.Arity; i++)
sb.Append(',');
sb.Append('>');
}
Expand Down Expand Up @@ -135,7 +135,7 @@ public static string GetTypeOfName(ISymbol? symbol)
if (namedTypeSymbol.IsOpenGenericType())
{
sb.Append('<');
for (var i = 1; i < namedTypeSymbol.Arity - 1; i++)
for (var i = 1; i < namedTypeSymbol.Arity; i++)
sb.Append(',');
sb.Append('>');
}
Expand Down
15 changes: 15 additions & 0 deletions test/Analyzers.Tests/ProviderIntegrationTests/AutoMapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ private class Profile1 : Profile;

private class Mapper : Profile;

public class DocumentCreatedByValueResolver<TSource, TDestination> : DocumentStringMetadataValueResolver<TSource, TDestination>;

public abstract class DocumentStringMetadataValueResolver<TSource, TDestination> : IValueResolver<TSource, TDestination, string>
{
protected virtual string GetValue(string metadataValue)
{
throw new NotImplementedException();
}

public string Resolve(TSource source, TDestination destination, string destMember, ResolutionContext context)
{
throw new NotImplementedException();
}
}


private class A : IValueResolver<Source, Destination, string>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ IEnumerable<Type> IAssemblyProvider.GetTypes(Func<ITypeProviderAssemblySelector,
yield return RocketSurgeryConventionsAnalyzersTests.GetType("Rocket.Surgery.Conventions.Analyzers.Tests.ProviderIntegrationTests.AutoMapperTests+A");
yield return RocketSurgeryConventionsAnalyzersTests.GetType("Rocket.Surgery.Conventions.Analyzers.Tests.ProviderIntegrationTests.AutoMapperTests+C");
yield return RocketSurgeryConventionsAnalyzersTests.GetType("Rocket.Surgery.Conventions.Analyzers.Tests.ProviderIntegrationTests.AutoMapperTests+D");
yield return typeof(global::Rocket.Surgery.Conventions.Analyzers.Tests.ProviderIntegrationTests.AutoMapperTests.DocumentCreatedByValueResolver<, >);
yield return RocketSurgeryConventionsAnalyzersTests.GetType("Rocket.Surgery.Conventions.Analyzers.Tests.ProviderIntegrationTests.AutoMapperTests+E");
break;
}
Expand Down

0 comments on commit 18ff415

Please sign in to comment.