Skip to content

Instantly share code, notes, and snippets.

View controlflow's full-sized avatar

Alexander Shvedov controlflow

View GitHub Profile
var parameter = parameterInstance.Element;
if (parameter.Kind != ParameterKind.VALUE
&& parameter.Kind != ParameterKind.REFERENCE) return;
if (arguments[currentIndex].MatchingParameter?.Element.IndexOf() is {} index && index >= 0)
// vs.
if (arguments[currentIndex].MatchingParameter?.Element.IndexOf() is >= 0 and var index)
case IPredefinedTypeUsage predefinedTypeUsage:
return predefinedTypeUsage.Parent is IEnumBase
? null
: InspectPredefinedTypeUsage(predefinedTypeUsage, predefinedTypeUsage.ScalarPredefinedTypeName, boundSettingsStore);
public override AbstractValueWithInfo Divide(AbstractValue divisor)
{
switch (divisor)
{
case Scalar otherScalar when (otherScalar.Value == 0):
return AbstractValueWithInfo.DivisionByZero;
case Scalar otherScalar when (otherScalar.Value == 1):
return new AbstractValueWithInfo(this, ErrorType.DivisionByOne);
case Scalar otherScalar:
var result = Divide(myInterval, otherScalar.Value);
var argumentType = typeofExpression.ArgumentType;
if (!(argumentType is IDeclaredType declaredType)
|| declaredType.IsVoid()
|| declaredType is IDynamicType) return null;
var typeElement = declaredType.GetTypeElement();
if (typeElement is ITypeParameter) return null;
return typeElement?.TypeParameters.Count == 0 ? typeElement : null;
var operand = dagOwnerElement.SourceElement is IIsExpression sourceIsExpression ? sourceIsExpression.Operand
: dagOwnerElement.SourceElement is ISwitchStatement sourceSwitchStatement ? sourceSwitchStatement.GoverningExpression
: dagOwnerElement.SourceElement is ISwitchExpression sourceSwitchExpression ? sourceSwitchExpression.GoverningExpression
: null;
var str = obj as string;
if (str != null) {
WriteLine(str.Length);
}
var localFunctionDeclaration = declarationStatement.LocalFunctionDeclaration;
if (localFunctionDeclaration != null)
consumer.Add(localFunctionDeclaration.DeclaredElement);
var indexerDeclaration = declaration as IIndexerDeclaration;
if (indexerDeclaration != null)
{
var arrowClause = indexerDeclaration.ArrowClause;
if (arrowClause != null)
{
var property = indexerDeclaration.DeclaredElement;
if (property != null)
{
...
if (referenceExpression.QualifierType() is IDeclaredType declaredType)
{
if (declaredType.GetTypeElement() is IStruct @struct && @struct.IsByRefLike)
{
consumer.AddHighlighting(new RefStructMethodGroupsError(referenceExpression));
}
}