提交 856911af 编写于 作者: R Ravi Chande

When generating enums with auto insertion location = false, don't attempt to sort the members.

MAS should always disable auto insertion location.
上级 9a04e6ce
......@@ -100,7 +100,7 @@ private static CodeGenerationOptions CreateCodeGenerationOptions(Location contex
generateMethodBodies: false,
generateDocumentationComments: true,
mergeAttributes: false,
autoInsertionLocation: !((symbol is ITypeSymbol) && (symbol as ITypeSymbol).IsEnumType()));
autoInsertionLocation: false);
}
}
}
......@@ -262,7 +262,10 @@ protected static T Cast<T>(object value)
// Metadata as source generates complete declarations and doesn't modify
// existing ones. We can take the members to generate, sort them once,
// and then add them in that order to the end of the destination.
newMembers.Sort(GetMemberComparer());
if (!GeneratingEnum(members))
{
newMembers.Sort(GetMemberComparer());
}
currentDestination = this.AddMembers(currentDestination, newMembers);
}
......@@ -270,6 +273,13 @@ protected static T Cast<T>(object value)
return currentDestination;
}
private bool GeneratingEnum(IEnumerable<ISymbol> members)
{
// If we're generating an enum, every member will be an enum field
var field = members.FirstOrDefault() as IFieldSymbol;
return field != null && field.ContainingType.IsEnumType();
}
protected abstract IComparer<SyntaxNode> GetMemberComparer();
protected static CodeGenerationOptions CreateOptionsForMultipleMembers(CodeGenerationOptions options)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册