diff --git a/TypeSupport/TypeSupport/Extensions/PropertyOptions.cs b/TypeSupport/TypeSupport/Extensions/PropertyOptions.cs index 6c4161d..05ca848 100644 --- a/TypeSupport/TypeSupport/Extensions/PropertyOptions.cs +++ b/TypeSupport/TypeSupport/Extensions/PropertyOptions.cs @@ -32,5 +32,9 @@ public enum PropertyOptions : byte /// Properties that contain a collection indexer /// HasIndexer = 16, + /// + /// Do not include compiler generated types + /// + NoCompilerGenerated = 32, } } diff --git a/TypeSupport/TypeSupport/Extensions/TypeExtensions.cs b/TypeSupport/TypeSupport/Extensions/TypeExtensions.cs index 9e94ab4..8e8d87f 100644 --- a/TypeSupport/TypeSupport/Extensions/TypeExtensions.cs +++ b/TypeSupport/TypeSupport/Extensions/TypeExtensions.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Runtime.CompilerServices; namespace TypeSupport.Extensions { @@ -65,7 +66,11 @@ public static ICollection GetProperties(this Type type, Proper if (options.HasFlag(PropertyOptions.HasIndexer)) returnProperties = returnProperties.Where(x => x.GetIndexParameters().Any()); + if (options.HasFlag(PropertyOptions.NoCompilerGenerated)) + returnProperties = returnProperties.Where(x => !x.GetGetMethod(true).IsDefined(typeof(CompilerGeneratedAttribute), true)); + return returnProperties + .Where(x => !(x.Name == "EqualityContract" && x.PropertyType == typeof(Type))) .Select(x => new ExtendedProperty(x, propogateTypeSupportOptions)).ToList(); }