Created
April 10, 2012 07:16
-
-
Save mkrueger/2348979 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -64,44 +64,62 @@ | |
this.DecompileMethodBodies = true; | |
} | |
- public static bool MemberIsHidden(MemberReference member, DecompilerSettings settings) | |
+ public static bool MemberIsHidden (MemberReference member, DecompilerSettings settings) | |
{ | |
MethodDefinition method = member as MethodDefinition; | |
if (method != null) { | |
if (method.IsGetter || method.IsSetter || method.IsAddOn || method.IsRemoveOn) | |
return true; | |
- if (settings.AnonymousMethods && method.Name.StartsWith("<", StringComparison.Ordinal) && method.IsCompilerGenerated()) | |
+ if (settings.HideNonPublicMembers && !method.IsPublic) | |
+ return true; | |
+ if (settings.AnonymousMethods && method.Name.StartsWith ("<", StringComparison.Ordinal) && method.IsCompilerGenerated ()) | |
return true; | |
} | |
TypeDefinition type = member as TypeDefinition; | |
if (type != null) { | |
+ if (settings.HideNonPublicMembers && !type.IsPublic) | |
+ return true; | |
if (type.DeclaringType != null) { | |
- if (settings.AnonymousMethods && type.Name.StartsWith("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated()) | |
+ if (settings.AnonymousMethods && type.Name.StartsWith ("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated ()) | |
return true; | |
- if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(type)) | |
+ if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator (type)) | |
return true; | |
- } else if (type.IsCompilerGenerated()) { | |
- if (type.Name.StartsWith("<PrivateImplementationDetails>", StringComparison.Ordinal)) | |
+ } else if (type.IsCompilerGenerated ()) { | |
+ if (type.Name.StartsWith ("<PrivateImplementationDetails>", StringComparison.Ordinal)) | |
return true; | |
- if (type.IsAnonymousType()) | |
+ if (type.IsAnonymousType ()) | |
return true; | |
} | |
} | |
FieldDefinition field = member as FieldDefinition; | |
if (field != null) { | |
- if (field.IsCompilerGenerated()) { | |
- if (settings.AnonymousMethods && field.Name.StartsWith("CS$<>", StringComparison.Ordinal)) | |
+ if (settings.HideNonPublicMembers && !field.IsPublic) | |
+ return true; | |
+ if (field.IsCompilerGenerated ()) { | |
+ if (settings.AnonymousMethods && field.Name.StartsWith ("CS$<>", StringComparison.Ordinal)) | |
return true; | |
- if (settings.AutomaticProperties && field.Name.StartsWith("<", StringComparison.Ordinal) && field.Name.EndsWith("BackingField", StringComparison.Ordinal)) | |
+ if (settings.AutomaticProperties && field.Name.StartsWith ("<", StringComparison.Ordinal) && field.Name.EndsWith ("BackingField", StringComparison.Ordinal)) | |
return true; | |
} | |
// event-fields are not [CompilerGenerated] | |
- if (settings.AutomaticEvents && field.DeclaringType.Events.Any(ev => ev.Name == field.Name)) | |
+ if (settings.AutomaticEvents && field.DeclaringType.Events.Any (ev => ev.Name == field.Name)) | |
+ return true; | |
+ } | |
+ | |
+ PropertyDefinition property = member as PropertyDefinition; | |
+ if (property != null) { | |
+ if (settings.HideNonPublicMembers && (property.GetMethod == null || !property.GetMethod.IsPublic) && (property.SetMethod == null || !property.SetMethod.IsPublic)) | |
+ return true; | |
+ } | |
+ | |
+ EventDefinition evt = member as EventDefinition; | |
+ if (evt != null) { | |
+ if (settings.HideNonPublicMembers && (evt.AddMethod == null || !evt.AddMethod.IsPublic) && (evt.RemoveMethod == null || !evt.RemoveMethod.IsPublic)) | |
return true; | |
} | |
- | |
+ | |
return false; | |
} | |
@@ -234,7 +234,18 @@ | |
set { | |
if (showXmlDocumentation != value) { | |
showXmlDocumentation = value; | |
- OnPropertyChanged("ShowXmlDocumentation"); | |
+ OnPropertyChanged ("ShowXmlDocumentation"); | |
+ } | |
+ } | |
+ } | |
+ | |
+ bool hideNonPublicMembers = false; | |
+ public bool HideNonPublicMembers { | |
+ get { return hideNonPublicMembers; } | |
+ set { | |
+ if (hideNonPublicMembers != value) { | |
+ hideNonPublicMembers = value; | |
+ OnPropertyChanged ("HideNonPublicMembers"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment