forked from jburzynski/TypeGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying custom header and body as an attribute or spec
- Loading branch information
Showing
11 changed files
with
184 additions
and
12 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
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
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
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
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
21 changes: 21 additions & 0 deletions
21
src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomBodyTrait.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,21 @@ | ||
using TypeGen.Core.TypeAnnotations; | ||
|
||
namespace TypeGen.Core.SpecGeneration.Builders.Traits; | ||
|
||
internal class CustomBodyTrait<TSpecBuilder> : ICustomBodyTrait<TSpecBuilder> | ||
{ | ||
private readonly TSpecBuilder _this; | ||
private readonly TypeSpec _typeSpec; | ||
|
||
public CustomBodyTrait(TSpecBuilder @this, TypeSpec typeSpec) | ||
{ | ||
_this = @this; | ||
_typeSpec = typeSpec; | ||
} | ||
|
||
public TSpecBuilder CustomBody(string body) | ||
{ | ||
_typeSpec.SetCustomBody(body); | ||
return _this; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomHeaderTrait.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,21 @@ | ||
using TypeGen.Core.TypeAnnotations; | ||
|
||
namespace TypeGen.Core.SpecGeneration.Builders.Traits; | ||
|
||
internal class CustomHeaderTrait<TSpecBuilder> : ICustomHeaderTrait<TSpecBuilder> | ||
{ | ||
private readonly TSpecBuilder _this; | ||
private readonly TypeSpec _typeSpec; | ||
|
||
public CustomHeaderTrait(TSpecBuilder @this, TypeSpec typeSpec) | ||
{ | ||
_this = @this; | ||
_typeSpec = typeSpec; | ||
} | ||
|
||
public TSpecBuilder CustomHeader(string header) | ||
{ | ||
_typeSpec.SetCustomHeader(header); | ||
return _this; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomBodyTrait.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,10 @@ | ||
namespace TypeGen.Core.SpecGeneration.Builders.Traits; | ||
|
||
internal interface ICustomBodyTrait<TSpecBuilder> | ||
{ | ||
/// <summary> | ||
/// Indicates type has a custom body (equivalent of TsExportAttribute's CustomBody). | ||
/// </summary> | ||
/// <returns>The current instance of <see cref="TSpecBuilder"/>.</returns> | ||
TSpecBuilder CustomBody(string body); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomHeaderTrait.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,10 @@ | ||
namespace TypeGen.Core.SpecGeneration.Builders.Traits; | ||
|
||
internal interface ICustomHeaderTrait<TSpecBuilder> | ||
{ | ||
/// <summary> | ||
/// Indicates type has a custom header (equivalent of TsExportAttribute's CustomHeader). | ||
/// </summary> | ||
/// <returns>The current instance of <see cref="TSpecBuilder"/>.</returns> | ||
TSpecBuilder CustomHeader(string header); | ||
} |
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
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