本文整理汇总了C#中System.Compiler.Field.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Field.Equals方法的具体用法?C# Field.Equals怎么用?C# Field.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Compiler.Field
的用法示例。
在下文中一共展示了Field.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckField
private void CheckField(Field field) {
if (field == null) return;
// if method is StateIndependent then has to be readonly or field of an immutable type
if (Method.IsStateIndependent &&
!(field.IsInitOnly || (field.DeclaringType != null && field.DeclaringType.GetAttribute(SystemTypes.ImmutableAttribute) != null)))
this.IssueWarning();
if (field.Equals(PTGraph.allFields) || field.Equals(PTGraph.allFieldsNotOwned)) // reading all reachable fields not admissible
this.IssueWarning(); // NOTE: this could be refined by analysing whether only rep fields are reachable
// if got an [ElementRep] or [ElementPeer] field then saving element-level for next visit (rep:2, peer:1, none:0)
currentElementLevel = previousElementLevel;
if (Util.FieldIsElementsRepOrPeer(field))
previousElementLevel = (byte)(Util.FieldIsElementsRep(field) ? 2 : 1);
// first access in chain
if (firstBoundMember) {
firstBoundMember = false;
// non-rep: we go out of owned cone
if (!(field.IsRep || (field.Type != null && field.Type.IsValueType))) { // note: handling value types (e.g. structs) as owned
outsideOwnedCone = true;
}
else { // rep or struct
if (!(field.Type != null && field.Type.IsValueType)) // field of value-type (e.g. structs) does not lead into the owned cone
contextDepth = 1;
}
}
// chain should have ended already
else if (outsideOwnedCone) {
// access may be any of: visible field, readonly field, field of an immutable type, state-independent method
if (!(field.IsInitOnly || (field.DeclaringType != null && field.DeclaringType.GetAttribute(SystemTypes.ImmutableAttribute) != null)))
this.IssueWarning();
}
// access is rep or struct
else if (field.IsRep || (field.Type != null && field.Type is Struct)) {
if (field.Type != null && !(field.Type is Struct)) // if struct then do not go down (structs cannot be owned)
contextDepth++;
}
// access on an element of an ElementsPeer array (which means -1 level access relative to coll./array)
else if (currentElementLevel == 1) {
contextDepth--;
if (contextDepth < 1)
outsideOwnedCone = true;
}
// NOTE: elementLevel==2 need not be handled as we stay at the same context-depth
// access is not owned: we go outside of owned cone
else if (currentElementLevel != 2 && !field.IsPeer) {
outsideOwnedCone = true;
}
}