Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ public sealed class CodeGenerationContext
typeof(CodeGenerationContext).Assembly
};

/// <summary>
/// Add reference, support generic type
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public ISet<Assembly> AddReference(Type type)
{
if (type.IsGenericType)
{
var types = type.GetGenericArguments();
foreach (var t in types)
return AddReference(t);
}
else
this.References.Add(type.Assembly);
return References;
}

/// <summary>Gets the indent level.</summary>
/// <value>The indent level.</value>
public int IndentLevel { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public override bool TryGenerate(ServiceDescriptor serviceDescriptor, CodeGenera

foreach (var method in methods)
{
codeGenerationContext.References.Add(method.ReturnType.Assembly);
codeGenerationContext.AddReference(method.ReturnType);
foreach (var parameter in method.GetParameters())
{
codeGenerationContext.References.Add(parameter.ParameterType.Assembly);
codeGenerationContext.AddReference(parameter.ParameterType);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ public override bool TryGenerate(ServiceDescriptor serviceDescriptor, CodeGenera

foreach (var method in interceptableMethods)
{
codeGenerationContext.References.Add(method.ReturnType.Assembly);
codeGenerationContext.AddReference(method.ReturnType);
foreach (var parameter in method.GetParameters())
{
codeGenerationContext.References.Add(parameter.ParameterType.Assembly);
codeGenerationContext.AddReference(parameter.ParameterType);
}
}

Expand Down