Added a hidden route attribute that can be used to exclude a given route from code generation. Bumped package version to 1.2.1
This commit is contained in:
parent
5c2b2ea4ef
commit
60768b1b3e
@ -327,6 +327,20 @@ namespace MontoyaTech.Rest.Net
|
||||
/// <returns></returns>
|
||||
public static string GenerateCSharpClient(List<Route> routes, string name = "Client")
|
||||
{
|
||||
//Remove any hidden routes from code generation.
|
||||
for (int i = 0; i < routes.Count; i++)
|
||||
{
|
||||
var methodInfo = routes[i].GetTarget().GetMethodInfo();
|
||||
|
||||
var routeHidden = methodInfo.GetCustomAttribute<RouteHidden>();
|
||||
|
||||
if (routeHidden != null)
|
||||
{
|
||||
routes.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
var includedTypes = FindRoutesDependencies(routes);
|
||||
|
||||
var routeGroups = FindRouteGroups(routes);
|
||||
|
@ -17,7 +17,7 @@
|
||||
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
||||
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<Version>1.2.0</Version>
|
||||
<Version>1.2.1</Version>
|
||||
<PackageReleaseNotes></PackageReleaseNotes>
|
||||
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
|
||||
</PropertyGroup>
|
||||
|
20
Rest.Net/RouteHidden.cs
Normal file
20
Rest.Net/RouteHidden.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MontoyaTech.Rest.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// The outline of an Attribute to hide a given route for client code generation.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
public class RouteHidden : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a default RouteHidden attribute.
|
||||
/// </summary>
|
||||
public RouteHidden() { }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user