I am creating code that should check for equality using SyntaxGenerator
Example:
if (property.Type.IsValueType || property.Type == KnownSymbol.String) { if (property.Type.TypeKind == TypeKind.Enum || property.Type.GetMembers("op_Equality").Length == 1) { var valueEqualsExpression = syntaxGenerator.ValueEqualsExpression( SyntaxFactory.ParseName("value"), SyntaxFactory.ParseExpression(fieldAccess)); return (IfStatementSyntax)syntaxGenerator.IfStatement(valueEqualsExpression, new[] { SyntaxFactory.ReturnStatement() }); } ...
The problem is that this does not handle types like int .
I think I'm looking for something like SupportsValueEquals(ITypeSymbol symbol)
How can I find out if the type of equality supports through == ?
source share