请问有人可以解释一下为什么以下界面定义在Visual Studio 2010中编译时会出现错误吗?
[IncompleteCodePort(SourceOriginType.Other, "This should be a GL abstraction depending on what OpenGL API will be used")]
public interface IGL
{
/// <summary>
/// Returns true if provided function is available or supported by graphics API
/// </summary>
/// <param name="funcName"></param>
/// <returns></returns>
bool IsFunctionAvailable(string funcName);
/// <summary>
/// Returns true if provided function is supported as extension by graphics API
/// </summary>
/// <param name="funcName"></param>
/// <returns></returns>
bool IsExtensionAvailable(string funcName);
}
public class IncompleteCodePortAttribute : Attribute
{
public SourceOriginType SourceOriginType { get; private set; }
public string SourceUrl { get; private set; }
public string Reason { get; private set; }
public IncompleteCodePortAttribute(SourceOriginType originType, string reason, string sourceUrl = null)
{
SourceOriginType = originType;
SourceUrl = sourceUrl;
Reason = reason;
}
}
public enum SourceOriginType
{
CodePlex,
WorldWindJdk,
StackOverflow,
Other
}
我收到的错误信息是:
如果我删除自定义属性,则不会出现编译错误。属性参数必须是常量表达式、typeof 表达式或属性参数类型的数组创建表达式
IncompleteCodePort
?请列出它的所有构造函数。 - NawazIncompleteCodePort
类中使用枚举,请不要这样做。请改用SourceOriginType
。 - Corey