Skip to content

Instantly share code, notes, and snippets.

View controlflow's full-sized avatar

Alexander Shvedov controlflow

View GitHub Profile
if (referenceExpression.QualifierType() is IDeclaredType declaredType)
{
if (declaredType.GetTypeElement() is IStruct @struct && @struct.IsByRefLike)
{
consumer.AddHighlighting(new RefStructMethodGroupsError(referenceExpression));
}
}
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);
[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;
}
var elementType = GetElementType(declaredElement);
if (elementType is IDeclaredType declaredType)
{
var delegateInvokeMethod = declaredType.GetTypeElement<IDelegate>()?.InvokeMethod;
if (delegateInvokeMethod != null)
{
var returnType = declaredType.GetSubstitution()[delegateInvokeMethod.ReturnType];
if (returnType.IsValid())
{
switch (myJumpStatement)
{
case IReturnStatement returnStatement when returnStatement.Value != null:
ReplaceWithValue(returnStatement, returnStatement.Value);
break;
case IYieldStatement yieldStatement when yieldStatement.Expression != null:
ReplaceWithValue(yieldStatement, yieldStatement.Value);
break;
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.17763.805 (1809/October2018Update/Redstone5), VM=VMware
Intel Core i7-7700K CPU 4.20GHz (Kaby Lake), 1 CPU, 4 logical and 4 physical cores
.NET Core SDK=2.1.507
[Host] : .NET Core 2.1.11 (CoreCLR 4.6.27617.04, CoreFX 4.6.27617.02), X64 RyuJIT
DefaultJob : .NET Core 2.1.11 (CoreCLR 4.6.27617.04, CoreFX 4.6.27617.02), X64 RyuJIT
| Method | Count | Mean | Error | StdDev | Rank |
|--------------- |------ |------------:|----------:|----------:|-----:|
| IntArray | 1000 | 407.0 ns | 5.17 ns | 4.84 ns | 1 |
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.17763.805 (1809/October2018Update/Redstone5), VM=VMware
Intel Core i7-7700K CPU 4.20GHz (Kaby Lake), 1 CPU, 4 logical and 4 physical cores
[Host] : .NET Framework 4.8 (4.8.4018.0), X86 LegacyJIT
DefaultJob : .NET Framework 4.8 (4.8.4018.0), X86 LegacyJIT
| Method | Count | Mean | Error | StdDev | Rank |
|--------------- |------ |------------:|----------:|----------:|-----:|
| IntArray | 1000 | 260.9 ns | 3.25 ns | 3.04 ns | 1 |
| StringArray | 1000 | 3,372.6 ns | 25.71 ns | 22.79 ns | 4 |
switch (targetIdentifier.Name)
{
case "assembly":
return AttributeTargets.Assembly;
case "module":
return AttributeTargets.Module;
case "return":
return AttributeTargets.ReturnValue;
case "field":
return AttributeTargets.Field;
foreach (var sourceFile in transaction.GetProperties(typeof(SymbolCache)).OfType<Pair<IPsiSourceFile, bool>>())
{
SynchUpdateCacheForFile(sourceFile: sourceFile.First, isRollback: true, underTransaction: false, fireEvent: sourceFile.Second);
}
// 1
foreach (var x in xs)
using (var r = x.GetResource())
DoWork(x, r);
// 2
foreach (var x in xs)
using (var r = x.GetResource()) {
DoWork(x, r);