View foo.cs
This file contains 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.Concurrent; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
// the task is to Analyze() files in parallel and Process() them on the main thread in batches | |
var files = Enumerable.Range(0, 1000).Select(x => $"File{x:0000}.cs").ToList(); | |
var degreeOfParallelism = Math.Min(Environment.ProcessorCount, 8); |
View process.cs
This file contains 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.Concurrent; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
// the task is to Analyze() files in parallel and Process() them on the main thread in batches | |
var files = Enumerable.Range(0, 1000).Select(x => $"File{x:0000}.cs").ToList(); | |
var degreeOfParallelism = Math.Min(Environment.ProcessorCount, 8); |
View main.cs
This file contains 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.Runtime.CompilerServices; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Running; | |
// ReSharper disable RedundantToStringCall | |
// ReSharper disable NotAccessedField.Local | |
#pragma warning disable 169 | |
BenchmarkRunner.Run<NullChecksBenchmark>(); |
View foo1.cs
This file contains 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
case IProperty {IsAuto: false, IsStatic: false} autoProperty | |
when !autoProperty.CanBeOverridden() | |
&& (autoProperty.Setter == null || autoProperty.Setter.IsInitOnly): |
View foo1.cs
This file contains 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
private static bool IsPossibleCodeBehind(IFile file) | |
{ | |
return file is IFileImpl {SecondaryRangeTranslator: { } translator} && !(translator is IInjectedRangeTranslator); | |
} |
View foo1.cs
This file contains 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
if (pattern is IPatternWithDesignation withDesignation) | |
{ | |
var existingDesignation = withDesignation.Designation; | |
if (existingDesignation != null && !(existingDesignation is IDiscardDesignation)) return false; | |
} |
View foo1.cs
This file contains 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
if (declaredElement is ITypeElement && !(declaredElement is IDelegate)) | |
return false; | |
if (declaredElement is IFunction && !(declaredElement is IMethod) || declaredElement is ILabel || declaredElement is INamespace) | |
return false; |
View foo1.cs
This file contains 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 parameter = parameterInstance.Element; | |
if (parameter.Kind != ParameterKind.VALUE | |
&& parameter.Kind != ParameterKind.REFERENCE) return; |
View foo1.cs
This file contains 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
if (arguments[currentIndex].MatchingParameter?.Element.IndexOf() is {} index && index >= 0) | |
// vs. | |
if (arguments[currentIndex].MatchingParameter?.Element.IndexOf() is >= 0 and var index) |
View foo1.cs
This file contains 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
case IPredefinedTypeUsage predefinedTypeUsage: | |
return predefinedTypeUsage.Parent is IEnumBase | |
? null | |
: InspectPredefinedTypeUsage(predefinedTypeUsage, predefinedTypeUsage.ScalarPredefinedTypeName, boundSettingsStore); |
NewerOlder