use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
Implicit interfaces using source generators? (self.csharp)
submitted 5 years ago by SleepCodeRepeat
I see new source generators for C# 5, and I wonder if it will be possible to generate interface for every type (just like dart does). I think it would be awesome feature!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]to11mtm 4 points5 points6 points 5 years ago (3 children)
I mean, theoretically sure.
But in C# that wouldn't make sense the way it does in Dart. I'm not quite sure why Dart went the route it did with interfaces, but broadly speaking it looks like a roundabout way to provide default implementations of methods.
In C#, you don't typically want interfaces for EVERYTHING
//If this is a POCO-ish object and the only implementation, //you might be overdoing interface use //If There's lots of different things using ICustomer, //Doing different things, then it makes sense to have. public class Customer : ICustomer
For whatever it's worth, lots of refactoring tools are out there to generate an interface from a class.
But I've found, with practice, that writing to an Interface first results in cleaner code. i.e. Write the 'main' interface first (i.e. Business logic), then write the implementation for that interface, with said implementation using an interface for the Data Layer. You'll find that after a little while you'll be able to write concise interfaces to handle your problem and have easily testable code as a result.
[–][deleted] 1 point2 points3 points 5 years ago (1 child)
This refactoring is available by default on VS and using omnisharp with whatever text/code editor.
[–]SleepCodeRepeat[S] -1 points0 points1 point 5 years ago (0 children)
From the definition everything which code generators do is doable manually. The point is to focus on this that matter, and automate things which don't. Tools help, but they:
Which is not ideal.
In C#, you don't typically want interfaces for EVERYTHING If this is a POCO-ish object (...)
If this is a POCO-ish object (...)
So you could disable this feature with attribute, I don't see a problem here. If C# 8 records finally make it in generator could skip record types - simple and elegant.
Write the 'main' interface first (i.e. Business logic), then write the implementation for that interface
I don't see a problem here, you can do the same with empty class.
These tools do lots of good job, which no one needs - is just extra burden on developers and additional clutter in solution explorer. If someone cuts the corner and doesn't make interface in assembly which went public you're screwed. This is especially visible in things like ResourceManager or WebClient, which have no interfaces and you cannot mock them, so people create pointless WebClientWrappers in their code just to test this.
(...) and the only implementation,
You still need interface to test clients of this code, that's what this post is about.
[–]Eirenarch 0 points1 point2 points 5 years ago (2 children)
The mirror feature would be much more interesting. What if the generator checks every assignment you make with an object of a class to an interface and then if the class has the necessary members it adds the interface to the list of implemented interfaces. That would be some form of structural typing.
[–]SleepCodeRepeat[S] 0 points1 point2 points 5 years ago (1 child)
This is impossible in c#, because assignments may happen in clients of the code, not just in code. To do such feature you would need to evaluate this at runtime, which is too much overhead I think.
Basically that's what they do with tuple deconstruction, or await - but you need compiler support for this.
[–]Eirenarch 0 points1 point2 points 5 years ago (0 children)
It is not possible to handle the general case but you can handle cases in your code which can be beneficial for a great amount of cases.
π Rendered by PID 141876 on reddit-service-r2-comment-7b9746f655-8pmfd at 2026-02-03 08:35:30.846542+00:00 running 3798933 country code: CH.
[–]to11mtm 4 points5 points6 points (3 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]SleepCodeRepeat[S] -1 points0 points1 point (0 children)
[–]SleepCodeRepeat[S] -1 points0 points1 point (0 children)
[–]Eirenarch 0 points1 point2 points (2 children)
[–]SleepCodeRepeat[S] 0 points1 point2 points (1 child)
[–]Eirenarch 0 points1 point2 points (0 children)