top | item 44155926

(no title)

vnorilo | 9 months ago

The recent C# feature called interceptors [1] pretty much looks like comefrom from where I stand. Yet everyone talking about it has either been serious, or very good at trolling.

1: https://khalidabuhakmeh.com/dotnet-8-interceptors

discuss

order

skissane|9 months ago

From your link:

[InterceptsLocation("/Users/khalidabuhakmeh/RiderProjects/ConsoleApp12/ConsoleApp12/Program.cs", line: 3, character: 3)]

they added a language feature which is sensitive to precise line/character offsets in your source code, so the tiniest change to the source code invalidates your code…

I’m speechless. Whatever they are aiming to achieve here, surely there is a more elegant, less ugly way

poizan42|9 months ago

You are not supposed to use interceptors in code you write yourself. The feature exists for Roslyn Source Generators that runs every time you build the code.

pjmlp|9 months ago

I am completly against them, I think they have re-invented Microsoft Fakes, and PostSharp, only badly.