diff --git a/Directory.Build.props b/Directory.Build.props index 55df28cab3..26ff3e7175 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ 6.0.* 6.0.* 6.0.* - 4.1.* + 4.2.* 2.14.1 5.0.2 $(MSBuildThisFileDirectory)CodingGuidelines.ruleset @@ -34,7 +34,7 @@ 3.1.2 - 4.17.2 - 17.1.0 + 4.18.1 + 17.2.0 diff --git a/JsonApiDotNetCore.sln b/JsonApiDotNetCore.sln index 0a8ed12d2a..21b1cca7ce 100644 --- a/JsonApiDotNetCore.sln +++ b/JsonApiDotNetCore.sln @@ -46,8 +46,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestBuildingBlocks", "test\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.SourceGenerators", "src\JsonApiDotNetCore.SourceGenerators\JsonApiDotNetCore.SourceGenerators.csproj", "{952C0FDE-AFC8-455C-986F-6CC882ED8953}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGeneratorDebugger", "test\SourceGeneratorDebugger\SourceGeneratorDebugger.csproj", "{87D066F9-3540-4AC7-A748-134900969EE5}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGeneratorTests", "test\SourceGeneratorTests\SourceGeneratorTests.csproj", "{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.Annotations", "src\JsonApiDotNetCore.Annotations\JsonApiDotNetCore.Annotations.csproj", "{83FF097C-C8C6-477B-9FAB-DF99B84978B5}" @@ -232,18 +230,6 @@ Global {952C0FDE-AFC8-455C-986F-6CC882ED8953}.Release|x64.Build.0 = Release|Any CPU {952C0FDE-AFC8-455C-986F-6CC882ED8953}.Release|x86.ActiveCfg = Release|Any CPU {952C0FDE-AFC8-455C-986F-6CC882ED8953}.Release|x86.Build.0 = Release|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x64.ActiveCfg = Debug|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x64.Build.0 = Debug|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x86.ActiveCfg = Debug|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x86.Build.0 = Debug|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Release|Any CPU.Build.0 = Release|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x64.ActiveCfg = Release|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x64.Build.0 = Release|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x86.ActiveCfg = Release|Any CPU - {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x86.Build.0 = Release|Any CPU {0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -299,7 +285,6 @@ Global {EC3202C6-1D4C-4B14-A599-B9D3F27FE3BA} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} {210FD61E-FF5D-4CEE-8E0D-C739ECCCBA21} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} {952C0FDE-AFC8-455C-986F-6CC882ED8953} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} - {87D066F9-3540-4AC7-A748-134900969EE5} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} {0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} {83FF097C-C8C6-477B-9FAB-DF99B84978B5} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} {60334658-BE51-43B3-9C4D-F2BBF56C89CE} = {026FBC6C-AF76-4568-9B87-EC73457899FD} diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs index ca517e3e99..72669de585 100644 --- a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs +++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs @@ -1,9 +1,6 @@ using JetBrains.Annotations; using JsonApiDotNetCore.Controllers; -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - namespace JsonApiDotNetCore.Resources.Annotations; /// diff --git a/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs b/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs index 6728fd537c..65800bba82 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs +++ b/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs @@ -13,6 +13,12 @@ namespace JsonApiDotNetCore.SourceGenerators { + // To debug in Visual Studio (requires v17.2 or higher): + // - Set JsonApiDotNetCore.SourceGenerators as startup project + // - Add a breakpoint at the start of the Initialize or Execute method + // - Optional: change targetProject in Properties\launchSettings.json + // - Press F5 + [Generator(LanguageNames.CSharp)] public sealed class ControllerSourceGenerator : ISourceGenerator { diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj index 9f7c0b85dd..bcd8c06b0a 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj @@ -48,6 +48,6 @@ - + diff --git a/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json b/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json index 2679b059a9..03635841ec 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json +++ b/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "JsonApiDotNetCore.SourceGenerators": { "commandName": "DebugRoslynComponent", - "targetProject": "..\\..\\test\\SourceGeneratorDebugger\\SourceGeneratorDebugger.csproj" + "targetProject": "..\\Examples\\JsonApiDotNetCoreExample\\JsonApiDotNetCoreExample.csproj" } } } diff --git a/test/SourceGeneratorDebugger/Controllers/ArticlesController.cs b/test/SourceGeneratorDebugger/Controllers/ArticlesController.cs deleted file mode 100644 index 1ceafa5d02..0000000000 --- a/test/SourceGeneratorDebugger/Controllers/ArticlesController.cs +++ /dev/null @@ -1,16 +0,0 @@ -using JetBrains.Annotations; - -namespace SourceGeneratorDebugger.Controllers; - -// Workaround for https://youtrack.jetbrains.com/issue/RSRP-487028 -public partial class ArticlesController -{ -} - -[PublicAPI] -partial class ArticlesController -{ - public void ExtraMethod() - { - } -} diff --git a/test/SourceGeneratorDebugger/Controllers/CustomersController.cs b/test/SourceGeneratorDebugger/Controllers/CustomersController.cs deleted file mode 100644 index a10de41483..0000000000 --- a/test/SourceGeneratorDebugger/Controllers/CustomersController.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Configuration; -using JsonApiDotNetCore.Controllers; -using JsonApiDotNetCore.Services; -using Microsoft.Extensions.Logging; -using SourceGeneratorDebugger.Models; - -namespace SourceGeneratorDebugger.Controllers; - -[PublicAPI] -public sealed class CustomersController : JsonApiController -{ - public CustomersController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IResourceService resourceService) - : base(options, resourceGraph, loggerFactory, resourceService) - { - } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ArgumentGuard.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ArgumentGuard.cs deleted file mode 100644 index e806a3caa1..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ArgumentGuard.cs +++ /dev/null @@ -1,19 +0,0 @@ -using JetBrains.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name -#pragma warning disable AV1008 // Class should not be static - -namespace JsonApiDotNetCore; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -internal static class ArgumentGuard -{ - public static void NotNullNorEmpty(string? value, string name) - { - } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/AttrAttribute.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/AttrAttribute.cs deleted file mode 100644 index d8201a0a59..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/AttrAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -using JetBrains.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Resources.Annotations; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public sealed class AttrAttribute : Attribute -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/BaseJsonApiController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/BaseJsonApiController.cs deleted file mode 100644 index 2cd3fd0cd6..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/BaseJsonApiController.cs +++ /dev/null @@ -1,41 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Configuration; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Services; -using Microsoft.Extensions.Logging; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Controllers; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public abstract class BaseJsonApiController - where TResource : class, IIdentifiable -{ - protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IResourceService resourceService) - : this(options, resourceGraph, loggerFactory, resourceService, resourceService) - { - } - - protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IResourceQueryService? queryService = null, IResourceCommandService? commandService = null) - : this(options, resourceGraph, loggerFactory, queryService, queryService, queryService, queryService, commandService, commandService, commandService, - commandService, commandService, commandService) - { - } - - protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IGetAllService? getAll = null, IGetByIdService? getById = null, - IGetSecondaryService? getSecondary = null, IGetRelationshipService? getRelationship = null, - ICreateService? create = null, IAddToRelationshipService? addToRelationship = null, - IUpdateService? update = null, ISetRelationshipService? setRelationship = null, - IDeleteService? delete = null, IRemoveFromRelationshipService? removeFromRelationship = null) - { - } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IAddToRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IAddToRelationshipService.cs deleted file mode 100644 index 4bdfbe99ab..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IAddToRelationshipService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IAddToRelationshipService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ICreateService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ICreateService.cs deleted file mode 100644 index 3e1d7525a3..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ICreateService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface ICreateService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IDeleteService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IDeleteService.cs deleted file mode 100644 index 10a1092bd9..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IDeleteService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IDeleteService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetAllService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetAllService.cs deleted file mode 100644 index 9a6644e428..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetAllService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IGetAllService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetByIdService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetByIdService.cs deleted file mode 100644 index f59885af15..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetByIdService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IGetByIdService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetRelationshipService.cs deleted file mode 100644 index 7e28fe1cb1..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetRelationshipService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IGetRelationshipService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetSecondaryService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetSecondaryService.cs deleted file mode 100644 index 3d2d0fd381..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetSecondaryService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IGetSecondaryService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IIdentifiable.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IIdentifiable.cs deleted file mode 100644 index a5a857cf3e..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IIdentifiable.cs +++ /dev/null @@ -1,23 +0,0 @@ -using JetBrains.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Resources; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IIdentifiable -{ - string? StringId { get; set; } - string? LocalId { get; set; } -} - -[PublicAPI] -public interface IIdentifiable : IIdentifiable -{ - TId Id { get; set; } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IJsonApiOptions.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IJsonApiOptions.cs deleted file mode 100644 index 5d076dd4ca..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IJsonApiOptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using JetBrains.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Configuration; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IJsonApiOptions -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IRemoveFromRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IRemoveFromRelationshipService.cs deleted file mode 100644 index dd071fdc6e..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IRemoveFromRelationshipService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IRemoveFromRelationshipService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceCommandService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceCommandService.cs deleted file mode 100644 index e7fcebc608..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceCommandService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IResourceCommandService - : ICreateService, IAddToRelationshipService, IUpdateService, ISetRelationshipService, - IDeleteService, IRemoveFromRelationshipService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceGraph.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceGraph.cs deleted file mode 100644 index 7d1f1562ba..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceGraph.cs +++ /dev/null @@ -1,15 +0,0 @@ -using JetBrains.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Configuration; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IResourceGraph -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceQueryService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceQueryService.cs deleted file mode 100644 index b734963ad3..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceQueryService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IResourceQueryService - : IGetAllService, IGetByIdService, IGetRelationshipService, IGetSecondaryService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ISetRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ISetRelationshipService.cs deleted file mode 100644 index 2cd43448bd..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ISetRelationshipService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface ISetRelationshipService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IUpdateService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IUpdateService.cs deleted file mode 100644 index 974335097c..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IUpdateService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable UnusedTypeParameter -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IUpdateService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/Identifiable.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/Identifiable.cs deleted file mode 100644 index 6e78d67867..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/Identifiable.cs +++ /dev/null @@ -1,19 +0,0 @@ -using JetBrains.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Resources; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public abstract class Identifiable : IIdentifiable -{ - public virtual TId Id { get; set; } = default!; - - public string? StringId { get; set; } - public string? LocalId { get; set; } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiCommandController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiCommandController.cs deleted file mode 100644 index 31736e8088..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiCommandController.cs +++ /dev/null @@ -1,25 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Configuration; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Services; -using Microsoft.Extensions.Logging; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Controllers; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public abstract class JsonApiCommandController : BaseJsonApiController - where TResource : class, IIdentifiable -{ - protected JsonApiCommandController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IResourceCommandService commandService) - : base(options, resourceGraph, loggerFactory, null, commandService) - { - } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiController.cs deleted file mode 100644 index 9d7d1d6e9c..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiController.cs +++ /dev/null @@ -1,36 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Configuration; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Services; -using Microsoft.Extensions.Logging; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Controllers; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public abstract class JsonApiController : BaseJsonApiController - where TResource : class, IIdentifiable -{ - protected JsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IResourceService resourceService) - : base(options, resourceGraph, loggerFactory, resourceService) - { - } - - protected JsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IGetAllService? getAll = null, IGetByIdService? getById = null, - IGetSecondaryService? getSecondary = null, IGetRelationshipService? getRelationship = null, - ICreateService? create = null, IAddToRelationshipService? addToRelationship = null, - IUpdateService? update = null, ISetRelationshipService? setRelationship = null, - IDeleteService? delete = null, IRemoveFromRelationshipService? removeFromRelationship = null) - : base(options, resourceGraph, loggerFactory, getAll, getById, getSecondary, getRelationship, create, addToRelationship, update, setRelationship, - delete, removeFromRelationship) - { - } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiOptions.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiOptions.cs deleted file mode 100644 index bad4ca2a28..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiOptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// ReSharper disable CheckNamespace - -using JetBrains.Annotations; - -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Configuration; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public sealed class JsonApiOptions : IJsonApiOptions -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiQueryController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiQueryController.cs deleted file mode 100644 index cebb57e7bc..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiQueryController.cs +++ /dev/null @@ -1,25 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Configuration; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Services; -using Microsoft.Extensions.Logging; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Controllers; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public abstract class JsonApiQueryController : BaseJsonApiController - where TResource : class, IIdentifiable -{ - protected JsonApiQueryController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, - IResourceQueryService queryService) - : base(options, resourceGraph, loggerFactory, queryService) - { - } -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiResourceService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiResourceService.cs deleted file mode 100644 index 118f5d315d..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiResourceService.cs +++ /dev/null @@ -1,17 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public sealed class JsonApiResourceService : IResourceService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceGraph.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceGraph.cs deleted file mode 100644 index 5be951c9f4..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceGraph.cs +++ /dev/null @@ -1,15 +0,0 @@ -using JetBrains.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Configuration; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public sealed class ResourceGraph : IResourceGraph -{ -} diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceServiceInterfaces.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceServiceInterfaces.cs deleted file mode 100644 index 72cd018d77..0000000000 --- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceServiceInterfaces.cs +++ /dev/null @@ -1,17 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace JsonApiDotNetCore.Services; - -/// -/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully -/// compiling the source-generated controllers in this project. -/// -[PublicAPI] -public interface IResourceService : IResourceCommandService, IResourceQueryService - where TResource : class, IIdentifiable -{ -} diff --git a/test/SourceGeneratorDebugger/Models/Account.cs b/test/SourceGeneratorDebugger/Models/Account.cs deleted file mode 100644 index 360f6f837f..0000000000 --- a/test/SourceGeneratorDebugger/Models/Account.cs +++ /dev/null @@ -1,14 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Controllers; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Resources.Annotations; - -namespace SourceGeneratorDebugger.Models; - -[UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource(GenerateControllerEndpoints = JsonApiEndpoints.Query, ControllerNamespace = "Some.Namespace.To.Place.Controllers")] -public sealed class Account : Identifiable -{ - [Attr] - public string? DisplayName { get; set; } -} diff --git a/test/SourceGeneratorDebugger/Models/Article.cs b/test/SourceGeneratorDebugger/Models/Article.cs deleted file mode 100644 index fd28b80494..0000000000 --- a/test/SourceGeneratorDebugger/Models/Article.cs +++ /dev/null @@ -1,14 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Controllers; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Resources.Annotations; - -namespace SourceGeneratorDebugger.Models; - -[UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource(GenerateControllerEndpoints = JsonApiEndpoints.GetCollection | JsonApiEndpoints.GetSingle | JsonApiEndpoints.GetSecondary)] -public sealed class Article : Identifiable -{ - [Attr] - public string? DisplayName { get; set; } -} diff --git a/test/SourceGeneratorDebugger/Models/Customer.cs b/test/SourceGeneratorDebugger/Models/Customer.cs deleted file mode 100644 index 26d869c550..0000000000 --- a/test/SourceGeneratorDebugger/Models/Customer.cs +++ /dev/null @@ -1,12 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Resources.Annotations; - -namespace SourceGeneratorDebugger.Models; - -[UsedImplicitly(ImplicitUseTargetFlags.Members)] -public sealed class Customer : Identifiable -{ - [Attr] - public string Name { get; set; } = null!; -} diff --git a/test/SourceGeneratorDebugger/Models/Global.cs b/test/SourceGeneratorDebugger/Models/Global.cs deleted file mode 100644 index ef62b974ca..0000000000 --- a/test/SourceGeneratorDebugger/Models/Global.cs +++ /dev/null @@ -1,14 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Resources.Annotations; - -// ReSharper disable CheckNamespace -#pragma warning disable AV1505 // Namespace should match with assembly name - -[UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource] -public sealed class Global : Identifiable -{ - [Attr] - public string? Value { get; set; } -} diff --git a/test/SourceGeneratorDebugger/Models/Login.cs b/test/SourceGeneratorDebugger/Models/Login.cs deleted file mode 100644 index 334a395a21..0000000000 --- a/test/SourceGeneratorDebugger/Models/Login.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Controllers; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Resources.Annotations; - -#pragma warning disable AV1505 // Namespace should match with assembly name - -namespace SourceGeneratorDebugger.Models -{ - [UsedImplicitly(ImplicitUseTargetFlags.Members)] - [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Command)] - public sealed class Login : Identifiable - { - [Attr] - public DateTimeOffset Time { get; set; } - } -} - -namespace Some.Other.Path -{ - [UsedImplicitly(ImplicitUseTargetFlags.Members)] - [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Command)] - public sealed class Login : Identifiable - { - [Attr] - public DateTimeOffset Time { get; set; } - } -} diff --git a/test/SourceGeneratorDebugger/Models/Order.cs b/test/SourceGeneratorDebugger/Models/Order.cs deleted file mode 100644 index 40d5582ff1..0000000000 --- a/test/SourceGeneratorDebugger/Models/Order.cs +++ /dev/null @@ -1,14 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Controllers; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Resources.Annotations; - -namespace SourceGeneratorDebugger.Models; - -[UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource(GenerateControllerEndpoints = JsonApiEndpoints.All)] -public sealed class Order : Identifiable -{ - [Attr] - public decimal TotalAmount { get; set; } -} diff --git a/test/SourceGeneratorDebugger/Models/SimpleNamespace.cs b/test/SourceGeneratorDebugger/Models/SimpleNamespace.cs deleted file mode 100644 index ea02d20413..0000000000 --- a/test/SourceGeneratorDebugger/Models/SimpleNamespace.cs +++ /dev/null @@ -1,15 +0,0 @@ -using JetBrains.Annotations; -using JsonApiDotNetCore.Resources; -using JsonApiDotNetCore.Resources.Annotations; - -// ReSharper disable CheckNamespace - -namespace SourceGeneratorDebugger; - -[UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource] -public sealed class SimpleNamespace : Identifiable -{ - [Attr] - public string? Value { get; set; } -} diff --git a/test/SourceGeneratorDebugger/Program.cs b/test/SourceGeneratorDebugger/Program.cs deleted file mode 100644 index b237a86f68..0000000000 --- a/test/SourceGeneratorDebugger/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -using JsonApiDotNetCore.Configuration; -using JsonApiDotNetCore.Services; -using Microsoft.Extensions.Logging.Abstractions; -using SourceGeneratorDebugger.Controllers; -using SourceGeneratorDebugger.Models; - -namespace SourceGeneratorDebugger; - -// Until https://github.com/dotnet/roslyn/issues/55802 is fixed, this project enables us to debug the ASP.NET Controller source generator. -// In Visual Studio, set JsonApiDotNetCore.SourceGenerators as startup project, add a breakpoint at the start of ControllerSourceGenerator and press F5. -internal static class Program -{ - public static void Main() - { - JsonApiOptions options = new(); - ResourceGraph resourceGraph = new(); - - // Built-in - IResourceService customerResourceService = new JsonApiResourceService(); - CustomersController customersController = new(options, resourceGraph, NullLoggerFactory.Instance, customerResourceService); - GC.KeepAlive(customersController); - - // Generated - IResourceService orderResourceService = new JsonApiResourceService(); - OrdersController ordersController = new(options, resourceGraph, NullLoggerFactory.Instance, orderResourceService); - GC.KeepAlive(ordersController); - - // Generated Query - IResourceQueryService accountQueryService = new JsonApiResourceService(); - AccountsController accountsController = new(options, resourceGraph, NullLoggerFactory.Instance, accountQueryService); - GC.KeepAlive(accountsController); - - // Generated Command - IResourceCommandService loginCommandService = new JsonApiResourceService(); - LoginsController loginsController = new(options, resourceGraph, NullLoggerFactory.Instance, loginCommandService); - GC.KeepAlive(loginsController); - - // Generated mix - IGetAllService articleGetAllResourceService = new JsonApiResourceService(); - IGetByIdService articleGetByIdResourceService = new JsonApiResourceService(); - IGetSecondaryService articleGetSecondaryResourceService = new JsonApiResourceService(); - - ArticlesController articlesController = new(options, resourceGraph, NullLoggerFactory.Instance, articleGetAllResourceService, - articleGetByIdResourceService, articleGetSecondaryResourceService); - - articlesController.ExtraMethod(); - - // Generated in global namespace - IResourceService globalResourceService = new JsonApiResourceService(); - GlobalsController globalsController = new(options, resourceGraph, NullLoggerFactory.Instance, globalResourceService); - GC.KeepAlive(globalsController); - - // Generated in non-nested namespace - IResourceService singleNamespaceResourceService = new JsonApiResourceService(); - SimpleNamespacesController singleNamespacesController = new(options, resourceGraph, NullLoggerFactory.Instance, singleNamespaceResourceService); - GC.KeepAlive(singleNamespacesController); - } -} diff --git a/test/SourceGeneratorDebugger/SourceGeneratorDebugger.csproj b/test/SourceGeneratorDebugger/SourceGeneratorDebugger.csproj deleted file mode 100644 index 2909905e2b..0000000000 --- a/test/SourceGeneratorDebugger/SourceGeneratorDebugger.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - $(TargetFrameworkName) - Exe - true - $(BaseIntermediateOutputPath)\GeneratedFiles - - - - - - - - - - - - - - - - - - - - - diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj index 68db5c994c..2f383d72e9 100644 --- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj +++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj @@ -10,13 +10,13 @@ - + - +