Created
May 11, 2020 14:44
-
-
Save MikeCodesDotNET/3492a844090f8b7d94d25f4a42a75f6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void ValidatePropertyDeclarationSyntax(PropertyDeclarationSyntax declarationSyntax) | |
{ | |
IPropertySymbol symbol = semanticModel.GetDeclaredSymbol(declarationSyntax) as IPropertySymbol; | |
if (symbol.IsStatic) | |
{ | |
errors.Add((ValidationErrorType.Illegal_Feature, "Static properties are not allowed")); | |
return; | |
} | |
if (symbol.IsOverride) | |
{ | |
errors.Add((ValidationErrorType.Illegal_Feature, "Overriding properties is not allowed")); | |
return; | |
} | |
if (symbol.IsAbstract) | |
{ | |
errors.Add((ValidationErrorType.Illegal_Feature, "Abstract properties are not allowed")); | |
return; | |
} | |
if (symbol.IsVirtual) | |
{ | |
errors.Add((ValidationErrorType.Illegal_Feature, "Virtual properties are not allowed")); | |
return; | |
} | |
string assemblyName = symbol.Type.ContainingAssembly.Name; | |
if (IsIllegalAssemblyName(assemblyName)) | |
{ | |
errors.Add((ValidationErrorType.Illegal_Assembly, $"Types from assembly {assemblyName} are not allowed")); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment