cab8fa82a2
* Added a new Fody plugin to add to every model class the JsonExtensionData attribute * retargeted fody plugin to netstandard for msbuild runtime * Fixed runtime issue * Fixed property check for new extension data properties --------- Co-authored-by: Alex <clodanSPT@hotmail.com>
37 lines
950 B
C#
37 lines
950 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Mono.Cecil;
|
|
|
|
namespace JsonExtensionData.Fody;
|
|
|
|
public static class CecilExtensions
|
|
{
|
|
public static List<TypeDefinition> GetAllClasses(this ModuleDefinition moduleDefinition)
|
|
{
|
|
var definitions = new List<TypeDefinition>();
|
|
//First is always module so we will skip that;
|
|
GetTypes(moduleDefinition.Types.Skip(1), definitions);
|
|
return definitions;
|
|
}
|
|
|
|
static void GetTypes(IEnumerable<TypeDefinition> typeDefinitions, List<TypeDefinition> definitions)
|
|
{
|
|
foreach (var typeDefinition in typeDefinitions)
|
|
{
|
|
GetTypes(typeDefinition.NestedTypes, definitions);
|
|
|
|
if (typeDefinition.IsInterface)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (typeDefinition.IsEnum)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
definitions.Add(typeDefinition);
|
|
}
|
|
}
|
|
}
|