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
namespace MemberAccessors | |
{ | |
using System.Collections.Concurrent; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
#nullable enable | |
/// <summary> | |
/// A helper class for accessing fields and properties of an object in a performant way. | |
/// </summary> | |
public class MemberAccessor<T> |
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
This is a comment about the following blog post: https://hamedfathi.me/the-dotnet-world-csharp-source-generator/ | |
I just skimmed through the post because its quite long tbh, so this is not a review but rather an impression. | |
When I was blogging I was asking myself some questions: | |
- Who's my audience? | |
- What's the goal and the story of the blogpost? | |
- Is there any redundant infromation that I've added to the post that can be removoed without making the main point less clear? etc. | |
Even though I think soomeone will love the posts like the one we're talking about (and the content is great, btw), this is not the post I'll be reading carefully. |
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
public class TypeTuple : IEquatable<TypeTuple> | |
{ | |
public bool Equals(TypeTuple other) | |
{ | |
if (ReferenceEquals(null, other)) return false; | |
return EqualityComparer<Type>.Default.Equals(this.Source, other.Source) && | |
EqualityComparer<Type>.Default.Equals(this.Destination, other.Destination); | |
} | |
public override bool Equals(object obj) |
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
// Infinite loop | |
var x = new { Items = new List<int> { 1, 2, 3 }.GetEnumerator() }; | |
while (x.Items.MoveNext()) | |
{ | |
Console.WriteLine(x.Items.Current); | |
} | |
// Mutable struct used in all the following samples | |
struct Mutable | |
{ |
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; | |
interface IBase {} | |
interface IFoo : IBase | |
{ | |
int A {get;} | |
} | |
class Foo : IFoo | |
{ | |
public int A {get;set;} | |
} |
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.Threading.Tasks; | |
using System; | |
class NamingConventions | |
{ | |
public static async Task DoStuffAsync() | |
{ | |
await Task.Delay(); | |
} | |
public static Task DoAnotherStuffAsync() |
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
class CornerCaseSample | |
{ | |
private readonly Lazy<int> _lazy; | |
public CornerCaseSample(string s) | |
{ | |
// Any issues with this code? | |
Contract.Requires(s != null); | |
_lazy = new Lazy<int>(() => s.Length); | |
} |
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.Reflection; | |
using System.Runtime.ExceptionServices; | |
using FunctionalWeapon.Monads; | |
using NUnit.Framework; | |
namespace NoThrow.Tests | |
{ | |
public struct NoThrow<T> | |
{ |
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 list = new List<int>{42}; | |
var lIter = list.GetEnumerator(); | |
lIter.MoveNext(); | |
list.Add(12); | |
Console.WriteLine(lIter.Current); // 1 | |
Console.WriteLine(lIter.MoveNext()); // 2 | |
// Тоже самое но с LinkedList | |
var linked = new LinkedList<int>(); |
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; | |
public class TreeMap | |
{ | |
private TreeMapNode topNode = null; | |
public void Add(IComparable key, object value) | |
{ | |
if (topNode == null) | |
topNode = new TreeMapNode(key, value); | |
else |
NewerOlder