Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Shvedov controlflow

View GitHub Profile
View foo1.cs
case IPredefinedTypeUsage predefinedTypeUsage:
return predefinedTypeUsage.Parent is IEnumBase
? null
: InspectPredefinedTypeUsage(predefinedTypeUsage, predefinedTypeUsage.ScalarPredefinedTypeName, boundSettingsStore);
View foo1.cs
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);
View foo1.cs
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;
View foo1.cs
var operand = dagOwnerElement.SourceElement is IIsExpression sourceIsExpression ? sourceIsExpression.Operand
: dagOwnerElement.SourceElement is ISwitchStatement sourceSwitchStatement ? sourceSwitchStatement.GoverningExpression
: dagOwnerElement.SourceElement is ISwitchExpression sourceSwitchExpression ? sourceSwitchExpression.GoverningExpression
: null;
View foo1.cs
var str = obj as string;
if (str != null) {
WriteLine(str.Length);
}
View foo1.cs
var localFunctionDeclaration = declarationStatement.LocalFunctionDeclaration;
if (localFunctionDeclaration != null)
consumer.Add(localFunctionDeclaration.DeclaredElement);
View foo1.cs
var indexerDeclaration = declaration as IIndexerDeclaration;
if (indexerDeclaration != null)
{
var arrowClause = indexerDeclaration.ArrowClause;
if (arrowClause != null)
{
var property = indexerDeclaration.DeclaredElement;
if (property != null)
{
...
View foo1.cs
if (referenceExpression.QualifierType() is IDeclaredType declaredType)
{
if (declaredType.GetTypeElement() is IStruct @struct && @struct.IsByRefLike)
{
consumer.AddHighlighting(new RefStructMethodGroupsError(referenceExpression));
}
}
View foo1.cs
public override bool Accepts(IDeclaredElement declaredElement, ISubstitution substitution)
{
switch (declaredElement)
{
case ISymbolAlias symbolAlias:
{
var aliasedSymbol = symbolAlias.GetAliasedSymbol();
if (aliasedSymbol == null) return true;
return Accepts(aliasedSymbol.Element, aliasedSymbol.Substitution);
View foo1.cs
[NotNull, Pure]
public static IPattern UnwrapFromSandbox([NotNull] this IPattern pattern)
{
if (pattern.Parent is ISandBox sandBox
&& sandBox.ContextType == SandBoxContextType.Replace
&& sandBox.ContextNode is IPattern replacedPattern)
{
return replacedPattern;
}