Skip to content

Commit

Permalink
chore: make dumped anonymous type descriptions look more like they do…
Browse files Browse the repository at this point in the history
… in LINQPad
  • Loading branch information
rdavisau committed Apr 28, 2019
1 parent fc3a827 commit ee10371
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DumpEditable/Helpers/DynamicTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace LINQPad.DumpEditable.Helpers
// adapted from https://stackoverflow.com/a/3862241/752273
public static class DynamicTypeBuilder
{
private const string AnonymousTypeIndicator = "<>f__AnonymousType";
private const string AnonymousTypeReplacement = "ø";

public static Type CreateTypeForEditor(object source, List<PropertyEditor> properties)
{
var tb = GetTypeBuilder(source);
Expand All @@ -30,6 +33,9 @@ private static TypeBuilder GetTypeBuilder(object source)
? $"{type.Namespace}.{type.Name}"
: type.Name;

if (typeSignature.StartsWith(AnonymousTypeIndicator))
typeSignature = AnonymousTypeReplacement;

var an = new AssemblyName(typeSignature);
var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run);
var moduleBuilder = assemblyBuilder.DefineDynamicModule("MainModule");
Expand Down

0 comments on commit ee10371

Please sign in to comment.