From 5955f03a37ef70e204dd65a3cddb7f44ebb68a8c Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 3 Jun 2026 09:51:39 +0200 Subject: [PATCH 1/2] Add analyzer --- .../ConflictingIdAttributeAnalyzer.cs | 224 ++++++ .../Core/src/Types.Analyzers/Errors.cs | 9 + .../Properties/SourceGenResources.Designer.cs | 9 + .../Properties/SourceGenResources.resx | 3 + .../Types.Analyzers/WellKnownAttributes.cs | 2 + .../ConflictingIdAttributeAnalyzerTests.cs | 663 ++++++++++++++++++ .../test/Types.Analyzers.Tests/TestHelper.cs | 3 +- ...lExceptIdMember_When_IdMemberIsNotFirst.md | 98 +++ ...d_FlagSecondMember_When_NoMemberNamedId.md | 87 +++ ...r_When_CollectionShapesShareElementType.md | 69 ++ ...ror_When_EnumerableElementMatchesScalar.md | 69 ++ ...iseError_When_EnumerableInnerTypesMatch.md | 69 ++ ...eError_When_ExplicitTypeNameIsSpecified.md | 69 ++ ...aiseError_When_GenericIdAttributeIsUsed.md | 69 ++ ...seError_When_GenericTypeArgumentsDiffer.md | 69 ++ ..._Should_NotRaiseError_When_IdTypesMatch.md | 69 ++ ...seError_When_NullableMatchesNonNullable.md | 69 ++ ...otRaiseError_When_TypeNameStringsDiffer.md | 69 ++ ...Error_When_ValueTaskResultMatchesScalar.md | 69 ++ ...orOnMismatchedMember_When_IdTypesDiffer.md | 87 +++ ...smatchedMethod_When_IdMethodTypesDiffer.md | 87 +++ ...RaiseError_When_ArrayElementTypesDiffer.md | 87 +++ ...seError_When_EnumerableInnerTypesDiffer.md | 87 +++ ...iseError_When_InterfaceHasMismatchedIds.md | 87 +++ ..._RaiseError_When_ListElementTypesDiffer.md | 87 +++ ...r_When_NestedTaskListElementTypesDiffer.md | 87 +++ ...aiseError_When_NullableValueTypesDiffer.md | 87 +++ ...SameGenericTypeNameHasMismatchedIdTypes.md | 87 +++ ..._SameTypeNameStringHasMismatchedIdTypes.md | 87 +++ ...d_RaiseError_When_TaskResultTypesDiffer.md | 87 +++ 30 files changed, 2744 insertions(+), 1 deletion(-) create mode 100644 src/HotChocolate/Core/src/Types.Analyzers/ConflictingIdAttributeAnalyzer.cs create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/ConflictingIdAttributeAnalyzerTests.cs create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_CollectionShapesShareElementType.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableElementMatchesScalar.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableInnerTypesMatch.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ExplicitTypeNameIsSpecified.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericIdAttributeIsUsed.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericTypeArgumentsDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_IdTypesMatch.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_NullableMatchesNonNullable.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_TypeNameStringsDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ValueTaskResultMatchesScalar.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md create mode 100644 src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md diff --git a/src/HotChocolate/Core/src/Types.Analyzers/ConflictingIdAttributeAnalyzer.cs b/src/HotChocolate/Core/src/Types.Analyzers/ConflictingIdAttributeAnalyzer.cs new file mode 100644 index 00000000000..afc2263175b --- /dev/null +++ b/src/HotChocolate/Core/src/Types.Analyzers/ConflictingIdAttributeAnalyzer.cs @@ -0,0 +1,224 @@ +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace HotChocolate.Types.Analyzers; + +[DiagnosticAnalyzer(LanguageNames.CSharp)] +public sealed class ConflictingIdAttributeAnalyzer : DiagnosticAnalyzer +{ + // Every [ID] member without a type name shares the declaring type's inferred GraphQL type name. + // Since each named type is analyzed in isolation, a single constant key is sufficient. + private const string InferredTypeNameKey = "inferred"; + + public override ImmutableArray SupportedDiagnostics { get; } = + [Errors.ConflictingIdAttribute]; + + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + context.RegisterSymbolAction(AnalyzeNamedType, SymbolKind.NamedType); + } + + private static void AnalyzeNamedType(SymbolAnalysisContext context) + { + var namedType = (INamedTypeSymbol)context.Symbol; + + if (namedType.TypeKind is not (TypeKind.Class or TypeKind.Struct or TypeKind.Interface)) + { + return; + } + + // Group all [ID] members of the type by their effective GraphQL type-name key, + // preserving source order within each group. + Dictionary>? groups = null; + + foreach (var member in namedType.GetMembers()) + { + ITypeSymbol? memberType = member switch + { + IPropertySymbol property => property.Type, + IMethodSymbol { MethodKind: MethodKind.Ordinary } method => method.ReturnType, + _ => null + }; + + if (memberType is null) + { + continue; + } + + var idAttribute = GetIdAttribute(member); + if (idAttribute is null) + { + continue; + } + + var idMember = new IdMember(member, UnwrapRuntimeIdType(memberType), idAttribute.Value.Attribute); + + groups ??= []; + if (!groups.TryGetValue(idAttribute.Value.TypeNameKey, out var members)) + { + members = []; + groups[idAttribute.Value.TypeNameKey] = members; + } + + members.Add(idMember); + } + + if (groups is null) + { + return; + } + + foreach (var group in groups.Values) + { + AnalyzeGroup(context, group); + } + } + + private static void AnalyzeGroup(SymbolAnalysisContext context, List group) + { + if (group.Count < 2) + { + return; + } + + // The authoritative member is the [ID] member named "Id" (case-insensitive) + // if one exists, otherwise the first [ID] member in source order. + var authoritative = group[0]; + foreach (var candidate in group) + { + if (string.Equals(candidate.Member.Name, "Id", StringComparison.OrdinalIgnoreCase)) + { + authoritative = candidate; + break; + } + } + + foreach (var idMember in group) + { + if (ReferenceEquals(idMember, authoritative)) + { + continue; + } + + if (SymbolEqualityComparer.Default.Equals(idMember.RuntimeIdType, authoritative.RuntimeIdType)) + { + continue; + } + + var syntaxReference = idMember.Attribute.ApplicationSyntaxReference; + if (syntaxReference is null) + { + continue; + } + + var diagnostic = Diagnostic.Create( + Errors.ConflictingIdAttribute, + syntaxReference.GetSyntax(context.CancellationToken).GetLocation(), + idMember.Member.Name, + authoritative.Member.Name, + authoritative.RuntimeIdType.ToDisplayString()); + + context.ReportDiagnostic(diagnostic); + } + } + + private static (string TypeNameKey, AttributeData Attribute)? GetIdAttribute(ISymbol member) + { + foreach (var attribute in member.GetAttributes()) + { + var attributeClass = attribute.AttributeClass; + if (attributeClass is null) + { + continue; + } + + if (attributeClass.Name != "IDAttribute" + || attributeClass.ContainingNamespace?.ToDisplayString() != "HotChocolate.Types.Relay") + { + continue; + } + + // The generic IDAttribute derives its type name from the type argument. + if (attributeClass is { IsGenericType: true, TypeArguments.Length: 1 }) + { + return ("generic:" + attributeClass.TypeArguments[0].ToDisplayString(), attribute); + } + + // An explicit string type name forms its own group. + if (attribute.ConstructorArguments.Length > 0 + && attribute.ConstructorArguments[0].Value is string typeName) + { + return ("literal:" + typeName, attribute); + } + + // No type name was supplied, so the GraphQL type name is inferred from the + // declaring type and shared across all such [ID] members of that type. + return (InferredTypeNameKey, attribute); + } + + return null; + } + + private static ITypeSymbol UnwrapRuntimeIdType(ITypeSymbol type) + { + while (true) + { + if (type is IArrayTypeSymbol arrayType) + { + type = arrayType.ElementType; + continue; + } + + if (type is INamedTypeSymbol { IsGenericType: true } namedType) + { + var constructedFrom = namedType.ConstructedFrom.ToDisplayString(); + + if (constructedFrom is "System.Threading.Tasks.Task" + or "System.Threading.Tasks.ValueTask" + or "System.Nullable") + { + type = namedType.TypeArguments[0]; + continue; + } + + var elementType = GetEnumerableElementType(namedType); + if (elementType is not null) + { + type = elementType; + continue; + } + } + + return type; + } + } + + private static ITypeSymbol? GetEnumerableElementType(INamedTypeSymbol namedType) + { + // Strings implement IEnumerable but must be treated as scalar IDs. + if (namedType.SpecialType == SpecialType.System_String) + { + return null; + } + + if (namedType.ConstructedFrom.SpecialType == SpecialType.System_Collections_Generic_IEnumerable_T) + { + return namedType.TypeArguments[0]; + } + + foreach (var @interface in namedType.AllInterfaces) + { + if (@interface.ConstructedFrom.SpecialType == SpecialType.System_Collections_Generic_IEnumerable_T) + { + return @interface.TypeArguments[0]; + } + } + + return null; + } + + private sealed record IdMember(ISymbol Member, ITypeSymbol RuntimeIdType, AttributeData Attribute); +} diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Errors.cs b/src/HotChocolate/Core/src/Types.Analyzers/Errors.cs index fd7a87ae6c4..4a408745e8a 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Errors.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Errors.cs @@ -274,4 +274,13 @@ public static class Errors category: "TypeSystem", DiagnosticSeverity.Error, isEnabledByDefault: true); + + public static readonly DiagnosticDescriptor ConflictingIdAttribute = + new( + id: "HC0115", + title: "Conflicting [ID] attribute ID types", + messageFormat: SourceGenResources.ConflictingIdAttribute, + category: "TypeSystem", + DiagnosticSeverity.Error, + isEnabledByDefault: true); } diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs index 4dcfcccd2bf..94b16564b0e 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs @@ -59,6 +59,15 @@ internal SourceGenResources() { } } + /// + /// Looks up a localized string similar to The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name. + /// + internal static string ConflictingIdAttribute { + get { + return ResourceManager.GetString("ConflictingIdAttribute", resourceCulture); + } + } + /// /// Looks up a localized string similar to The DataLoader access modifier must be public or internal. /// diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx index 04ee5074021..a6ae6b53c24 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx +++ b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx @@ -21,6 +21,9 @@ A DataLoader must at least provides a key or keys parameter + + The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name. + The DataLoader access modifier must be public or internal diff --git a/src/HotChocolate/Core/src/Types.Analyzers/WellKnownAttributes.cs b/src/HotChocolate/Core/src/Types.Analyzers/WellKnownAttributes.cs index 28208bd4833..1acc5d20a78 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/WellKnownAttributes.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/WellKnownAttributes.cs @@ -21,6 +21,8 @@ public static class WellKnownAttributes public const string SubscriptionAttribute = "HotChocolate.SubscriptionAttribute"; public const string SubscribeAttribute = "HotChocolate.Types.SubscribeAttribute"; public const string NodeResolverAttribute = "HotChocolate.Types.Relay.NodeResolverAttribute"; + public const string IdAttribute = "HotChocolate.Types.Relay.IDAttribute"; + public const string GenericIdAttribute = "HotChocolate.Types.Relay.IDAttribute`1"; public const string ParentAttribute = "HotChocolate.ParentAttribute"; public const string EventMessageAttribute = "HotChocolate.EventMessageAttribute"; public const string ServiceAttribute = "HotChocolate.ServiceAttribute"; diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/ConflictingIdAttributeAnalyzerTests.cs b/src/HotChocolate/Core/test/Types.Analyzers.Tests/ConflictingIdAttributeAnalyzerTests.cs new file mode 100644 index 00000000000..adfdd371df6 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/ConflictingIdAttributeAnalyzerTests.cs @@ -0,0 +1,663 @@ +namespace HotChocolate.Types; + +public class ConflictingIdAttributeAnalyzerTests +{ + [Fact] + public async Task Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID] + public Guid AnotherTypeId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_ExplicitTypeNameIsSpecified() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID("Foo")] + public Guid AnotherTypeId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_GenericIdAttributeIsUsed() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID] + public Guid AnotherTypeId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_IdTypesMatch() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID] + public int AnotherTypeId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_NullableMatchesNonNullable() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID] + public int? AnotherTypeId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_EnumerableElementMatchesScalar() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System.Collections.Generic; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID] + public IEnumerable AnotherTypeId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [InterfaceType] + public static partial class ThingType + { + } + + public interface IThing + { + [ID] + int Id { get; } + + [ID] + Guid AnotherTypeId { get; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int GetId() => 1; + + [ID] + public Guid GetOther() => Guid.NewGuid(); + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_FlagSecondMember_When_NoMemberNamedId() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int FirstId { get; set; } + + [ID] + public Guid SecondId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public Guid FooId { get; set; } + + [ID] + public int Id { get; set; } + + [ID] + public string BarId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using System.Collections.Generic; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public IEnumerable Id { get; set; } + + [ID] + public IEnumerable OtherIds { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_EnumerableInnerTypesMatch() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System.Collections.Generic; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public IEnumerable Id { get; set; } + + [ID] + public IEnumerable OtherIds { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Foo; + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID] + public Guid Other { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID("Shared")] + public int Id { get; set; } + + [ID("Shared")] + public Guid Other { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_TypeNameStringsDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID("A")] + public int Id { get; set; } + + [ID("B")] + public Guid Other { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_GenericTypeArgumentsDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Foo; + + public class Bar; + + public class Thing + { + [ID] + public int Id { get; set; } + + [ID] + public Guid Other { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_ArrayElementTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int[] Id { get; set; } + + [ID] + public Guid[] OtherIds { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_ListElementTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using System.Collections.Generic; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public List Id { get; set; } + + [ID] + public List OtherIds { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_CollectionShapesShareElementType() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System.Collections.Generic; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int[] Id { get; set; } + + [ID] + public IEnumerable Two { get; set; } + + [ID] + public List Three { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_TaskResultTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using System.Threading.Tasks; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public Task GetId() => Task.FromResult(1); + + [ID] + public Task GetOther() => Task.FromResult(Guid.NewGuid()); + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_NotRaiseError_When_ValueTaskResultMatchesScalar() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System.Threading.Tasks; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public ValueTask GetId() => new ValueTask(1); + + [ID] + public int Other { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_NullableValueTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public int? Id { get; set; } + + [ID] + public Guid? OtherId { get; set; } + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } + + [Fact] + public async Task Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer() + { + await TestHelper.GetGeneratedSourceSnapshot( + [""" + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using HotChocolate.Types; + using HotChocolate.Types.Relay; + + namespace TestNamespace; + + [ObjectType] + public static partial class ThingType + { + } + + public class Thing + { + [ID] + public Task> GetId() => Task.FromResult(new List()); + + [ID] + public Task> GetOther() => Task.FromResult(new List()); + } + """], + enableAnalyzers: true).MatchMarkdownAsync(); + } +} diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/TestHelper.cs b/src/HotChocolate/Core/test/Types.Analyzers.Tests/TestHelper.cs index 6737b92db28..e43543b378d 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/TestHelper.cs +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/TestHelper.cs @@ -222,7 +222,8 @@ private static Snapshot CreateSnapshot(CSharpCompilation compilation, GeneratorD new IdAttributeOnRecordParameterAnalyzer(), new WrongAuthorizationAttributeAnalyzer(), new LookupReturnsNonNullableTypeAnalyzer(), - new LookupReturnsListTypeAnalyzer()); + new LookupReturnsListTypeAnalyzer(), + new ConflictingIdAttributeAnalyzer()); var compilationWithAnalyzers = compilation.WithAnalyzers(analyzers); var analyzerDiagnostics = compilationWithAnalyzers.GetAllDiagnosticsAsync().Result; diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md new file mode 100644 index 00000000000..7019d8df0fd --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md @@ -0,0 +1,98 @@ +# Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (13,5)-(13,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'FooId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'FooId' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + }, + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (19,5)-(19,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'BarId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'BarId' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md new file mode 100644 index 00000000000..c70f8a3a94b --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md @@ -0,0 +1,87 @@ +# Analyze_Should_FlagSecondMember_When_NoMemberNamedId + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (16,5)-(16,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'SecondId' maps to the same ID type name as 'FirstId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'SecondId' to use the same type as 'FirstId' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_CollectionShapesShareElementType.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_CollectionShapesShareElementType.md new file mode 100644 index 00000000000..ce74d830752 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_CollectionShapesShareElementType.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_CollectionShapesShareElementType + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableElementMatchesScalar.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableElementMatchesScalar.md new file mode 100644 index 00000000000..304beb1546a --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableElementMatchesScalar.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_EnumerableElementMatchesScalar + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableInnerTypesMatch.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableInnerTypesMatch.md new file mode 100644 index 00000000000..de1fe35b4f5 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_EnumerableInnerTypesMatch.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_EnumerableInnerTypesMatch + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ExplicitTypeNameIsSpecified.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ExplicitTypeNameIsSpecified.md new file mode 100644 index 00000000000..af5513a5309 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ExplicitTypeNameIsSpecified.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_ExplicitTypeNameIsSpecified + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericIdAttributeIsUsed.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericIdAttributeIsUsed.md new file mode 100644 index 00000000000..61255d67108 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericIdAttributeIsUsed.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_GenericIdAttributeIsUsed + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericTypeArgumentsDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericTypeArgumentsDiffer.md new file mode 100644 index 00000000000..eab38942770 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_GenericTypeArgumentsDiffer.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_GenericTypeArgumentsDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_IdTypesMatch.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_IdTypesMatch.md new file mode 100644 index 00000000000..8719cd7a2c5 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_IdTypesMatch.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_IdTypesMatch + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_NullableMatchesNonNullable.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_NullableMatchesNonNullable.md new file mode 100644 index 00000000000..b5ab2d36993 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_NullableMatchesNonNullable.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_NullableMatchesNonNullable + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_TypeNameStringsDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_TypeNameStringsDiffer.md new file mode 100644 index 00000000000..fd43b51845b --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_TypeNameStringsDiffer.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_TypeNameStringsDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ValueTaskResultMatchesScalar.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ValueTaskResultMatchesScalar.md new file mode 100644 index 00000000000..a0ff942a416 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_NotRaiseError_When_ValueTaskResultMatchesScalar.md @@ -0,0 +1,69 @@ +# Analyze_Should_NotRaiseError_When_ValueTaskResultMatchesScalar + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md new file mode 100644 index 00000000000..496ae6f349f --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (16,5)-(16,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'AnotherTypeId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'AnotherTypeId' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md new file mode 100644 index 00000000000..7eaa324cb63 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (16,5)-(16,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md new file mode 100644 index 00000000000..0f0c6fc9677 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_ArrayElementTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (16,5)-(16,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md new file mode 100644 index 00000000000..284ca9a5b6a --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (17,5)-(17,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md new file mode 100644 index 00000000000..105a1ac0565 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IInterfaceTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IInterfaceTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (16,5)-(16,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'AnotherTypeId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'AnotherTypeId' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md new file mode 100644 index 00000000000..f5b11c6f8b3 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_ListElementTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (17,5)-(17,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md new file mode 100644 index 00000000000..dd7c8c51e8a --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (18,5)-(18,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md new file mode 100644 index 00000000000..82ccee9c0f2 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_NullableValueTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (16,5)-(16,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'OtherId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherId' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md new file mode 100644 index 00000000000..41ff7140669 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (18,5)-(18,12)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'Other' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'Other' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md new file mode 100644 index 00000000000..135731e81a9 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (16,5)-(16,17)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'Other' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'Other' to use the same type as 'Id' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md new file mode 100644 index 00000000000..aa15ef990dc --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md @@ -0,0 +1,87 @@ +# Analyze_Should_RaiseError_When_TaskResultTypesDiffer + +## HotChocolateTypeModule.735550c.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.ThingType", + () => global::TestNamespace.ThingType.Initialize)); + builder.AddType>(); + return builder; + } + } +} + +``` + +## ThingType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs + +```csharp +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + public static partial class ThingType + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + } + } +} + + +``` + +## Analyzer Diagnostics + +```json +[ + { + "Id": "HC0115", + "Title": "Conflicting [ID] attribute ID types", + "Severity": "Error", + "WarningLevel": 0, + "Location": ": (17,5)-(17,7)", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", + "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name.", + "Category": "TypeSystem", + "CustomTags": [] + } +] +``` From 737900d21c717f30ee56a95caca4eb0d57f75033 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:06:32 +0200 Subject: [PATCH 2/2] Improve analyzer error --- .../Properties/SourceGenResources.Designer.cs | 2 +- .../Types.Analyzers/Properties/SourceGenResources.resx | 2 +- ...hould_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md | 8 ++++---- ...nalyze_Should_FlagSecondMember_When_NoMemberNamedId.md | 4 ++-- ...uld_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md | 4 ++-- ...iseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md | 4 ++-- ...lyze_Should_RaiseError_When_ArrayElementTypesDiffer.md | 4 ++-- ...e_Should_RaiseError_When_EnumerableInnerTypesDiffer.md | 4 ++-- ...ze_Should_RaiseError_When_InterfaceHasMismatchedIds.md | 4 ++-- ...alyze_Should_RaiseError_When_ListElementTypesDiffer.md | 4 ++-- ...ld_RaiseError_When_NestedTaskListElementTypesDiffer.md | 4 ++-- ...yze_Should_RaiseError_When_NullableValueTypesDiffer.md | 4 ++-- ...eError_When_SameGenericTypeNameHasMismatchedIdTypes.md | 4 ++-- ...seError_When_SameTypeNameStringHasMismatchedIdTypes.md | 4 ++-- ...nalyze_Should_RaiseError_When_TaskResultTypesDiffer.md | 4 ++-- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs index 94b16564b0e..a57cd09aca3 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.Designer.cs @@ -60,7 +60,7 @@ internal SourceGenResources() { } /// - /// Looks up a localized string similar to The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name. + /// Looks up a localized string similar to The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID<T>] or [ID("TypeName")]. /// internal static string ConflictingIdAttribute { get { diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx index a6ae6b53c24..bd8ad051794 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx +++ b/src/HotChocolate/Core/src/Types.Analyzers/Properties/SourceGenResources.resx @@ -22,7 +22,7 @@ A DataLoader must at least provides a key or keys parameter - The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name. + The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID<T>] or [ID("TypeName")]. The DataLoader access modifier must be public or internal diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md index 7019d8df0fd..93a073d8f74 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagAllExceptIdMember_When_IdMemberIsNotFirst.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (13,5)-(13,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'FooId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'FooId' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'FooId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'FooId' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] }, @@ -89,8 +89,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (19,5)-(19,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'BarId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'BarId' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'BarId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'BarId' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md index c70f8a3a94b..431f25ce437 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_FlagSecondMember_When_NoMemberNamedId.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (16,5)-(16,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'SecondId' maps to the same ID type name as 'FirstId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'SecondId' to use the same type as 'FirstId' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'SecondId' maps to the same ID type name as 'FirstId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'SecondId' to use the same type as 'FirstId' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md index 496ae6f349f..dee23d7618b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMember_When_IdTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (16,5)-(16,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'AnotherTypeId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'AnotherTypeId' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'AnotherTypeId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'AnotherTypeId' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md index 7eaa324cb63..d0c38f2bfd7 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseErrorOnMismatchedMethod_When_IdMethodTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (16,5)-(16,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md index 0f0c6fc9677..c5826e43d9c 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ArrayElementTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (16,5)-(16,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md index 284ca9a5b6a..66f2f476b5a 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_EnumerableInnerTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (17,5)-(17,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md index 105a1ac0565..a624025e645 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_InterfaceHasMismatchedIds.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (16,5)-(16,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'AnotherTypeId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'AnotherTypeId' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'AnotherTypeId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'AnotherTypeId' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md index f5b11c6f8b3..bbb7bf30e8f 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_ListElementTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (17,5)-(17,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'OtherIds' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherIds' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md index dd7c8c51e8a..ed3d1247b0b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NestedTaskListElementTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (18,5)-(18,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md index 82ccee9c0f2..d7c1ee80511 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_NullableValueTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (16,5)-(16,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'OtherId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherId' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'OtherId' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'OtherId' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md index 41ff7140669..bf93880c685 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameGenericTypeNameHasMismatchedIdTypes.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (18,5)-(18,12)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'Other' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'Other' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'Other' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'Other' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md index 135731e81a9..c663a6f73cb 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_SameTypeNameStringHasMismatchedIdTypes.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (16,5)-(16,17)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'Other' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'Other' to use the same type as 'Id' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'Other' maps to the same ID type name as 'Id', but their ID value types differ. An ID type name can only bind to a single value type, so change 'Other' to use the same type as 'Id' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md index aa15ef990dc..42f3a810bce 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ConflictingIdAttributeAnalyzerTests.Analyze_Should_RaiseError_When_TaskResultTypesDiffer.md @@ -78,8 +78,8 @@ namespace TestNamespace "Severity": "Error", "WarningLevel": 0, "Location": ": (17,5)-(17,7)", - "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name.", - "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name.", + "MessageFormat": "The [ID] attribute on '{0}' maps to the same ID type name as '{1}', but their ID value types differ. An ID type name can only bind to a single value type, so change '{0}' to use the same type as '{1}' ('{2}'), or give it a different type name with [ID] or [ID(\"TypeName\")].", + "Message": "The [ID] attribute on 'GetOther' maps to the same ID type name as 'GetId', but their ID value types differ. An ID type name can only bind to a single value type, so change 'GetOther' to use the same type as 'GetId' ('int'), or give it a different type name with [ID] or [ID(\"TypeName\")].", "Category": "TypeSystem", "CustomTags": [] }