-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1192 from json-api-dotnet/multi-target-annotations
Multi-target Annotations against .NET Standard 1.0
- Loading branch information
Showing
19 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrAttribute.netstandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace JsonApiDotNetCore.Resources.Annotations; | ||
|
||
/// <summary> | ||
/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class AttrAttribute : ResourceFieldAttribute | ||
{ | ||
/// <summary /> | ||
public AttrCapabilities Capabilities { get; set; } | ||
} |
3 changes: 3 additions & 0 deletions
3
...Resources/Annotations/AttrCapabilities.cs → ...es/Annotations/AttrCapabilities.shared.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/JsonApiDotNetCore.Annotations/Resources/Annotations/EagerLoadAttribute.netstandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace JsonApiDotNetCore.Resources.Annotations; | ||
|
||
/// <summary> | ||
/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class EagerLoadAttribute : Attribute | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasManyAttribute.netstandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace JsonApiDotNetCore.Resources.Annotations; | ||
|
||
/// <summary> | ||
/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class HasManyAttribute : RelationshipAttribute | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasOneAttribute.netstandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace JsonApiDotNetCore.Resources.Annotations; | ||
|
||
/// <summary> | ||
/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class HasOneAttribute : RelationshipAttribute | ||
{ | ||
} |
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.netstandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace JsonApiDotNetCore.Resources.Annotations; | ||
|
||
/// <summary> | ||
/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore. | ||
/// </summary> | ||
[PublicAPI] | ||
public abstract class RelationshipAttribute : ResourceFieldAttribute | ||
{ | ||
/// <summary /> | ||
public LinkTypes Links { get; set; } = LinkTypes.NotConfigured; | ||
|
||
/// <summary /> | ||
public bool CanInclude { get; set; } = true; | ||
} |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
...JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.netstandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace JsonApiDotNetCore.Resources.Annotations; | ||
|
||
/// <summary> | ||
/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore. | ||
/// </summary> | ||
[PublicAPI] | ||
public abstract class ResourceFieldAttribute : Attribute | ||
{ | ||
/// <summary /> | ||
public string PublicName { get; set; } = null!; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/JsonApiDotNetCore.Annotations/Resources/Identifiable.netstandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace JsonApiDotNetCore.Resources; | ||
|
||
/// <summary> | ||
/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore. | ||
/// </summary> | ||
public abstract class Identifiable<TId> : IIdentifiable<TId> | ||
{ | ||
/// <summary /> | ||
public virtual TId Id { get; set; } = default!; | ||
|
||
/// <summary /> | ||
public string? StringId { get; set; } | ||
|
||
/// <summary /> | ||
public string? LocalId { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>$(TargetFrameworkName);netstandard1.0</TargetFrameworks> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Update="xunit.runner.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' "> | ||
<Using Remove="System.Net.Http" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\JsonApiDotNetCore.Annotations\JsonApiDotNetCore.Annotations.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using JetBrains.Annotations; | ||
using JsonApiDotNetCore.Resources; | ||
using JsonApiDotNetCore.Resources.Annotations; | ||
|
||
namespace AnnotationTests.Models; | ||
|
||
[PublicAPI] | ||
[NoResource] | ||
[ResourceLinks(TopLevelLinks = LinkTypes.None, ResourceLinks = LinkTypes.None, RelationshipLinks = LinkTypes.None)] | ||
public sealed class HiddenNode : Identifiable<Guid> | ||
{ | ||
[EagerLoad] | ||
public HiddenNode? Parent { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using JetBrains.Annotations; | ||
using JsonApiDotNetCore.Controllers; | ||
using JsonApiDotNetCore.Resources; | ||
using JsonApiDotNetCore.Resources.Annotations; | ||
|
||
namespace AnnotationTests.Models; | ||
|
||
[PublicAPI] | ||
[Resource(PublicName = "tree-node", ControllerNamespace = "Models", GenerateControllerEndpoints = JsonApiEndpoints.Query)] | ||
public sealed class TreeNode : Identifiable<long> | ||
{ | ||
[Attr(PublicName = "name", Capabilities = AttrCapabilities.AllowSort)] | ||
public string? DisplayName { get; set; } | ||
|
||
[HasOne(PublicName = "orders", CanInclude = true, Links = LinkTypes.All)] | ||
public TreeNode? Parent { get; set; } | ||
|
||
[HasMany(PublicName = "orders", CanInclude = true, Links = LinkTypes.All)] | ||
public ISet<TreeNode> Children { get; set; } = new HashSet<TreeNode>(); | ||
} |