/// <summary> /// Mark the given reference reachable /// </summary> internal static void MarkReachable(this MemberReference memberRef, IReachableContext context) { if ((memberRef != null) && (!memberRef.IsReachable)) { memberRef.SetReachable(context); } }
/// <summary> /// Mark the given reference reachable /// </summary> internal static void MarkReachable(this MemberReference memberRef, IReachableContext context, bool useInSerialization = false) { if (memberRef != null) { memberRef.SetReachable(context, useInSerialization); } }
/// <summary> /// Mark this type reachable. /// </summary> public void SetReachable(IReachableContext context, bool useInSerialization = false) { // Already reachable? if (reachable != 0 && (!useInSerialization || usedInSerialization != 0)) { return; } // Mark it reachable bool reachableChanged = Interlocked.Exchange(ref reachable, 1) == 0; bool serializationChanged = useInSerialization && Interlocked.Exchange(ref usedInSerialization, 1) == 0; if (reachableChanged || serializationChanged) { if (context != null) { context.NewReachableDetected(); // Member was not yet walked, do it now unless its a type that is not in the project if (ShouldWalk(context, this)) { context.Walk(this); } } } }
/// <summary> /// Should we walk through the member for all children? /// </summary> private static bool ShouldWalk(IReachableContext context, MemberReference member) { TypeReference typeRef = member as TypeReference; if (typeRef == null) { return true; } if (typeRef is GenericParameter) { return true; } if (typeRef is TypeSpecification) { return true; } return context.Contains(typeRef); }
/// <summary> /// Should we walk through the member for all children? /// </summary> private static bool ShouldWalk(IReachableContext context, AbstractReference member) { var typeRef = member as TypeReference; if (typeRef == null) { return(true); } return(context.Contains(typeRef)); }
/// <summary> /// Should we walk through the member for all children? /// </summary> private static bool ShouldWalk(IReachableContext context, MemberReference member) { TypeReference typeRef = member as TypeReference; if (typeRef == null) { return(true); } if (typeRef is GenericParameter) { return(true); } if (typeRef is TypeSpecification) { return(true); } return(context.Contains(typeRef)); }
/// <summary> /// Mark this type reachable. /// </summary> public void SetReachable(IReachableContext context) { // Already reachable? if (reachable != 0) { return; } // Mark it reachable if (Interlocked.Exchange(ref reachable, 1) == 0) { if (context != null) { context.NewReachableDetected(); // Member was not yet walked, do it now unless its a type that is not in the project if (ShouldWalk(context, this)) { context.Walk(this); } } } }
/// <summary> /// Should we walk through the member for all children? /// </summary> private static bool ShouldWalk(IReachableContext context, AbstractReference member) { var typeRef = member as TypeReference; if (typeRef == null) { return true; } return context.Contains(typeRef); }