-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rico Suter
committed
May 3, 2023
1 parent
fb37aa2
commit 0ce206e
Showing
5 changed files
with
61 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace NSwag.Generation | ||
{ | ||
internal static class GenericResultWrapperTypes | ||
{ | ||
internal static bool IsGenericWrapperType( string typeName ) | ||
=> | ||
typeName == "Task`1" || | ||
typeName == "ValueTask`1" || | ||
typeName == "JsonResult`1" || | ||
typeName == "ActionResult`1" | ||
; | ||
internal static bool IsGenericWrapperType(string typeName) => | ||
typeName == "Task`1" || | ||
typeName == "ValueTask`1" || | ||
typeName == "JsonResult`1" || | ||
typeName == "ActionResult`1"; | ||
|
||
internal static void RemoveGenericWrapperTypes<T>(ref T o, Func<T,string> getName, Func<T,T> unwrap) | ||
internal static T RemoveGenericWrapperTypes<T>(T type, Func<T, string> getName, Func<T, T> unwrap) | ||
{ | ||
// We iterate because a common signature is public async Task<ActionResult<T>> Action() | ||
while (IsGenericWrapperType(getName(o))) | ||
while (IsGenericWrapperType(getName(type))) | ||
{ | ||
o = unwrap(o); | ||
type = unwrap(type); | ||
} | ||
|
||
return type; | ||
} | ||
} | ||
} |
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