Modified the RestClientGenerator to prevent infinite dependency tracing. This method is a little cleaner too. Bumped package version to 1.8.8
This commit is contained in:
parent
f116be9908
commit
d0d64ef570
@ -17,7 +17,7 @@
|
||||
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
||||
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<Version>1.8.7</Version>
|
||||
<Version>1.8.8</Version>
|
||||
<PackageReleaseNotes></PackageReleaseNotes>
|
||||
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
|
@ -58,79 +58,49 @@ namespace MontoyaTech.Rest.Net
|
||||
/// Finds all the dependencies for a given type and returns them.
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="dependencies"></param>
|
||||
/// <returns></returns>
|
||||
protected internal virtual List<Type> FindTypeDependencies(Type type)
|
||||
protected internal virtual HashSet<Type> FindTypeDependencies(Type type, HashSet<Type> dependencies = null)
|
||||
{
|
||||
var dependencies = new HashSet<Type>();
|
||||
if (dependencies == null)
|
||||
dependencies = new HashSet<Type>();
|
||||
else if (dependencies.Contains(type))
|
||||
return dependencies;
|
||||
else if (!this.IsTypeDotNet(type))
|
||||
dependencies.Add(type);
|
||||
|
||||
var arguments = type.GetGenericArguments();
|
||||
|
||||
if (arguments != null)
|
||||
{
|
||||
foreach (var argument in arguments)
|
||||
{
|
||||
if (argument != type)
|
||||
{
|
||||
var types = this.FindTypeDependencies(argument);
|
||||
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
if (!dependencies.Contains(types[i]))
|
||||
dependencies.Add(types[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.FindTypeDependencies(argument, dependencies);
|
||||
|
||||
if (this.IsTypeDotNet(type))
|
||||
return dependencies.ToList();
|
||||
return dependencies;
|
||||
|
||||
dependencies.Add(type);
|
||||
|
||||
if (type.IsEnum)
|
||||
return dependencies.ToList();
|
||||
return dependencies;
|
||||
|
||||
{
|
||||
var types = this.FindTypeDependencies(type.BaseType);
|
||||
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
if (!dependencies.Contains(types[i]))
|
||||
dependencies.Add(types[i]);
|
||||
}
|
||||
this.FindTypeDependencies(type.BaseType, dependencies);
|
||||
|
||||
var fields = type.GetFields();
|
||||
|
||||
if (fields != null)
|
||||
{
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (field.IsPublic && !field.IsSpecialName && field.FieldType != type)
|
||||
{
|
||||
var types = this.FindTypeDependencies(field.FieldType);
|
||||
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
if (!dependencies.Contains(types[i]))
|
||||
dependencies.Add(types[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.FindTypeDependencies(field.FieldType, dependencies);
|
||||
|
||||
var properties = type.GetProperties();
|
||||
|
||||
if (properties != null)
|
||||
{
|
||||
foreach (var property in properties)
|
||||
{
|
||||
if (!property.IsSpecialName && property.GetSetMethod() != null && property.GetGetMethod() != null && property.PropertyType != type)
|
||||
{
|
||||
var types = this.FindTypeDependencies(property.PropertyType);
|
||||
this.FindTypeDependencies(property.PropertyType, dependencies);
|
||||
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
if (!dependencies.Contains(types[i]))
|
||||
dependencies.Add(types[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dependencies.ToList();
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user