Skip to content

Instantly share code, notes, and snippets.

View controlflow's full-sized avatar

Alexander Shvedov controlflow

View GitHub Profile
public void Run(ITreeNode element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
{
var ifStatement = element as IIfStatement;
if (ifStatement != null)
{
CheckCondition(ifStatement.Condition, consumer);
return;
}
var whileStatement = element as IWhileStatement;
if (from.PrevSibling != null && from.PrevSibling.GetTokenType() == CSharpTokenType.WHITE_SPACE)
from = from.PrevSibling;
public delegate ref int RefIntFunc();
public delegate ref T RefFunc<T>();
public delegate ref TReturn RefFunc<T, TReturn>(T arg);
public delegate ref TReturn RefFunc<T1, T2, TReturn>(T1 arg1, T2 arg2);
public interface IWithRefReturns {
ref int RefIntMethod();
ref string RefStringMethod();
ref int RefIntProperty { get; }
[Pure]
private static bool HasContainingUnclosedBlocks([NotNull] ILocalFunctionDeclaration localFunctionDeclaration)
{
foreach (var containingNode in localFunctionDeclaration.ContainingNodes())
{
var containingBlock = containingNode as IBlock;
if (containingBlock != null && containingBlock.RBrace == null) return true;
var switchBlock = containingNode as ISwitchBlock;
if (switchBlock != null && switchBlock.RBrace == null) return true;
public void Run(ITreeNode element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
{
var prefixOperatorExpression = element as IPrefixOperatorExpression;
if (prefixOperatorExpression != null)
{
switch (prefixOperatorExpression.PrefixOperatorType)
{
case PrefixOperatorType.PLUSPLUS:
case PrefixOperatorType.MINUSMINUS:
{
using System;
// ReSharper disable UnusedParameter.Local
// ReSharper disable UnusedVariable
// ReSharper disable FunctionRecursiveOnAllPaths
public class WriteTest
{
public void RefArgument<T>(ref T t) { }
public void LocalVariable()
public IType GetEqualityParameterType(int parameterIndex)
{
if (myCachedEqualityParameterTypes[parameterIndex] == null)
myCachedEqualityParameterTypes[parameterIndex] = myEqualitySubstitution.Apply(myParameters[parameterIndex].Type);
return myCachedEqualityParameterTypes[parameterIndex];
}
var pattern = Pattern;
var constantPattern = pattern as IConstantPattern;
if (constantPattern != null)
{
return IsTypeFromConstantPattern(constantPattern);
}
var declarationPattern = pattern as IDeclarationPattern;
if (declarationPattern != null)
[Pure]
private static bool IsFullyDiscardedDeconstructionExpression([NotNull] ITupleCreationExpression tupleCreationExpression)
{
foreach (var tupleArgument in tupleCreationExpression.ArgumentsEnumerable)
{
if (tupleArgument.NameIdentifier != null) return false;
if (tupleArgument.Colon != null) return false;
var tupleArgumentValue = tupleArgument.Value;
var typeCheckClassification = typeCheckType.ClassifyTypeAdvanced();
if (typeCheckClassification == TypeParameterOracle.Classification.REFERENCE_TYPE && sourceType.IsValueType())
return TypeCheckStaticAnalysisResult.AlwaysFalse;
if (typeCheckClassification == TypeParameterOracle.Classification.NON_NULLABLE_VALUE_TYPE && sourceType.IsReferenceType())
return TypeCheckStaticAnalysisResult.AlwaysFalse;