ICSharpCode.NRefactory.MonoCSharp.Struct.CheckStructCycles C# (CSharp) Method

CheckStructCycles() private method

private CheckStructCycles ( ) : bool
return bool
		bool CheckStructCycles ()
		{
			if (InTransit)
				return false;

			InTransit = true;
			foreach (var member in Members) {
				var field = member as Field;
				if (field == null)
					continue;

				TypeSpec ftype = field.Spec.MemberType;
				if (!ftype.IsStruct)
					continue;

				if (ftype is BuiltinTypeSpec)
					continue;

				foreach (var targ in ftype.TypeArguments) {
					if (!CheckFieldTypeCycle (targ)) {
						Report.Error (523, field.Location,
							"Struct member `{0}' of type `{1}' causes a cycle in the struct layout",
							field.GetSignatureForError (), ftype.GetSignatureForError ());
						break;
					}
				}

				//
				// Static fields of exactly same type are allowed
				//
				if (field.IsStatic && ftype == CurrentType)
					continue;

				if (!CheckFieldTypeCycle (ftype)) {
					Report.Error (523, field.Location,
						"Struct member `{0}' of type `{1}' causes a cycle in the struct layout",
						field.GetSignatureForError (), ftype.GetSignatureForError ());
					break;
				}
			}

			InTransit = false;
			return true;
		}