本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax.IsUnSafe方法的典型用法代码示例。如果您正苦于以下问题:C# ClassDeclarationSyntax.IsUnSafe方法的具体用法?C# ClassDeclarationSyntax.IsUnSafe怎么用?C# ClassDeclarationSyntax.IsUnSafe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax
的用法示例。
在下文中一共展示了ClassDeclarationSyntax.IsUnSafe方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitClassDeclaration
public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
{
if (node.IsUnSafe())
{
this.AppendCompileIssue(node, IssueType.Error, IssueId.UnsafeNotSupport);
return node;
}
var ctorInfos = this._semanticModel.GetDeclaredSymbol(node).InstanceConstructors;
if (ctorInfos.Count() > 1)
{
this.AppendCompileIssue(node, IssueType.Error, IssueId.CtorOverload);
return node;
}
bool isStaticType = false;
if (node.IsPartial())
this.AppendCompileIssue(node, IssueType.Error, IssueId.PartialNotSupport);
if (node.IsStaticType())
isStaticType = true;
List<MemberDeclarationSyntax> static_members = new List<MemberDeclarationSyntax>();
var classInfo = this._semanticModel.GetDeclaredSymbol(node);
_currentClass = classInfo.GetTypeSymbolName();
int total = 0;//Note:Total member count, calc in below loop.
foreach (var m in node.Members)
{
if (m.Kind() == SyntaxKind.PropertyDeclaration)
{
this.AppendCompileIssue(m, IssueType.Error, IssueId.PropertyDeclareNotSupport);
continue;
}
if (m.IsValidMemberKind() && (m.IsStaticMember() || _semanticModel.IsGlobalVariable(m)))
continue;
if (m.Kind() == SyntaxKind.FieldDeclaration && _semanticModel.IsNoCompile((m as FieldDeclarationSyntax)))
continue;
if (m.Kind() == SyntaxKind.MethodDeclaration && _semanticModel.IsNoCompile((m as MethodDeclarationSyntax)))
continue;
total++;
}
int memberCount = 0;
string strBaseClass;
if (node.BaseList != null)
{
var baseInfo = classInfo.BaseType;
if (!baseInfo.IsScriptSymbol())
{
this.AppendCompileIssue(node, IssueType.Error, IssueId.UseNonScript, baseInfo);
return node;
}
if (baseInfo.ContainingNamespace.Name == nameof(System) && baseInfo.Name == nameof(System.Object))
strBaseClass = _template.RootType;
else
strBaseClass = baseInfo.GetTypeSymbolName();
}
else
{
strBaseClass = _template.RootType;
}
string strInterfaces = this.MakeInterfacesList(node);
BasicClassTemplate classTemplate = _template.CreateClassTemplate(isStaticType);
classTemplate.Assign(BasicClassTemplate.CLASS, _currentClass).Assign("baseclass", strBaseClass).Assign("interfaces", strInterfaces);
_output.Write(node.Identifier, classTemplate.GetBeginString());
if (!isStaticType)
{
if (_indentType)
_output.IncreaseIndent();
}
foreach (var member in node.Members)
{
if (member.Kind() == SyntaxKind.PropertyDeclaration)
{
//Note:Must skip for the member count reason.
continue;
}
if (member.Kind() == SyntaxKind.ClassDeclaration)
{
this.AppendCompileIssue(member, IssueType.Error, IssueId.InnerClassNotSupport);
continue;
}
if (member.Kind() == SyntaxKind.ConstructorDeclaration)
{
var ctorSyntax = member as ConstructorDeclarationSyntax;
if (ctorSyntax.IsStaticMember())
//.........这里部分代码省略.........