This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using JetBrains.Annotations; | |
namespace Smth { | |
[PublicAPI] | |
public abstract class ReflectionTypeVisitor<T> { | |
public virtual T VisitSimpleType(Type type) => default(T); | |
public virtual T VisitConstructedType([NotNull] Type typeDefinition, [NotNull] Type[] typeArguments) => default(T); | |
public virtual T VisitTypeParameterType([NotNull] Type typeParameter) => default(T); | |
public virtual T VisitArrayType([NotNull] Type arrayType) => default(T); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using JetBrains.Annotations; | |
namespace JetBrains.VsIntegration.ProjectModel.PropertiesExtender | |
{ | |
public sealed class AggregatedPropertyDescriptor : PropertyDescriptor | |
{ | |
[NotNull] private readonly IList<PropertyDescriptor> myPropertyDescriptors; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
[ProvidesContext] IPredefinedType _predefinedTypes = ...; | |
void DoSomething(ITreeNode node) { | |
if (Check(node)) { | |
var expressionType = node.GetExpressionType(); | |
if (expressionType.Equals(node.GetPredefinedType().Bool) { | |
// ^^^^^^^^^^^^^^^^^^^^^^^^ | |
// Use aleady provided 'IPredefinedType' value from '_predefinedTypes' field | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
smth?.Foo() smth.Foo() | |
?.Foo() .Foo() | |
.Foo() ?.Foo() | |
?.Foo() .Foo() | |
.Foo() ?.Foo() | |
.Foo(); ?.Foo(); | |
// 2 | |
smth?.Foo() smth.Foo() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = e as T; | |
if (x != null) { | |
... | |
} else { | |
// no usages of 'x' here | |
} | |
// no usages of 'x' here too | |
// => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T t; | |
U u; | |
if ((t = x.P as T) != null && | |
(u = t.P as U) != null) { | |
// ... use u/t ... | |
} | |
// => | |
if (x.P is T t && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsInContantContext([NotNull] this ITreeNode context) | |
{ | |
foreach (var containingNode in context.ContainingNodes()) | |
{ | |
switch (containingNode) | |
{ | |
case IAttribute attribute: | |
case IConstantDeclaration constant: | |
case ILocalConstantDeclaration localConstant: | |
case IEnumMemberDeclaration enumMember: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public static class C { | |
public static void M() { | |
var xs = new Dictionary<int, string>(); | |
foreach ((int id, string key) in xs) { | |
// ... | |
// int a = 0, b = 1; | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var typeArgumentListScanKind = ScanTypeArgumentList(nameOptions); | |
if (typeArgumentListScanKind == ScanTypeArgumentListKind.DefiniteTypeArgumentList) return true; | |
if (typeArgumentListScanKind == ScanTypeArgumentListKind.PossibleTypeArgumentList) | |
{ | |
if ((nameOptions & NameOptions.InTypeList) != 0) | |
{ | |
return true; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (myLexer.TokenType == CSharpTokenType.DOT || | |
myLexer.TokenType == CSharpTokenType.DOUBLE_COLON) | |
{ | |
// ... | |
} | |
// => | |
while (myLexer.TokenType is var tt && (tt == CSharpTokenType.DOT || | |
tt == CSharpTokenType.DOUBLE_COLON)) |