Initial community discussion thread: dotnet/csharplang#140
public List<int> Prop => field ??= new();
using System.Reflection; | |
internal static class ReflectionUtils | |
{ | |
public static bool IsVisibleOutsideAssembly(Type type) | |
{ | |
return (type.Attributes & TypeAttributes.VisibilityMask) switch | |
{ | |
TypeAttributes.Public => true, | |
TypeAttributes.NestedFamily or TypeAttributes.NestedFamORAssem => IsVisibleOutsideAssembly(type.DeclaringType!), |
declare @databaseNameFilter sysname = '' | |
select | |
last_execution_time as LastExecutionTime, | |
last_elapsed_time * 0.000001 as ElapsedSeconds, | |
last_rows as LastRowCount, | |
total_rows as TotalRowCount, | |
execution_count as ExecutionCount, | |
objects.name as ObjectName, | |
SqlText.text as CommandText |
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
public abstract class ObservableObject : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler? PropertyChanged; | |
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) | |
{ | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Collections.Immutable; | |
using System.Collections.ObjectModel; | |
using System.Diagnostics; | |
using System.Diagnostics.CodeAnalysis; | |
using System.Linq; | |
using System.Threading; |
// Uses https://gist.github.com/jnm2/73d378c5b52547728de1148d72de522a | |
/// <summary> | |
/// Leaves the first line alone, but removes common indentation from the remaining lines. | |
/// </summary> | |
public static string RemoveIndentation(string syntax) | |
{ | |
var commonWhitespaceLength = GetCommonWhitespace(syntax).Length; | |
return string.Create( |
public ref struct LineEnumerator(ReadOnlySpan<char> text) | |
{ | |
private ReadOnlySpan<char> text = text == default ? "" : text; | |
public bool MoveNext() | |
{ | |
if (text == default) | |
return false; | |
var nextEnd = text.IndexOf('\n'); |
Initial community discussion thread: dotnet/csharplang#140
public List<int> Prop => field ??= new();
Properties that use the field
keyword will not have warnings such as
For properties that have a get
accessor with a body and which use field
, analyze using this pseudocode, providing the same warnings as we would with accessors as local functions.
void Prop()
{
T? field = default;
declare @schemaName sysname = 'dbo' | |
declare @tableName sysname = 'ItemPrices' | |
declare @rowCondition nvarchar(max) = 'PriceCode in (''SEEDS'', ''YEAREND'')' | |
declare @builder nvarchar(max); | |
select @builder = coalesce(@builder + ' | |
', '') + 'if exists( | |
select *' + QueryWithoutSelect + ') |
flowchart
ICollection --- IEnumerable
IList --- ICollection
IEnumerableT[IEnumerable<T>] --- IEnumerable
ICollectionT[ICollection<T>] --- IEnumerableT
IListT[IList<T>] --- ICollectionT
IReadOnlyCollectionT[IReadOnlyCollection<T>] --- IEnumerableT
IReadOnlyListT[IReadOnlyList<T>] --- IReadOnlyCollectionT