Assemblies as Friends in C#
Vložit
- čas přidán 5. 02. 2023
- In this session, I'm going to show you how classes or assemblies can be friends in C#. This means that some private members, methods or classes in some assembly will only be exposed to friend assembly but not others.
This feature is extremely important for test-driven systems and shared assemblies or libraries or nuget packages with external consumers.
Here's a reference to this feature here:
learn.microsoft.com/en-us/dot...
Here's a link to LeVent project:
github.com/hassanhabib/LeVent
I was actually fiddling with clean architecture, making everything internal and faced a problem that I don't know how to expose the internals to unit test projects. This solves my problem. Super useful, thank you!
Great to hear!
+1
faced the same problem just yesterday!
@Hassan Habib do you have psychic powers?
Of course, if you have, you'll have to deny it to protect your secret identity, I totally understand 😁 👍
Thank you so much Hassan, this is very helpful.
Hot kteys make it hard to follow, but good explanation overall. Yes one of the problems with runtimes is security or a negative trade off
Would that be used for class libraries which shares information too (If you have your models that are used in multiple projects in a separate project) or would you keep this classes public then?
Like always an very interesting video! Thank you 😊
Models are not super big concern if they are anemic (data carriers). But services certainly not.
When we do this [assembly...] - it relates to the whole namespace or only to the part of this namespace declared in this certain file?
Because we can divede oure classes which are in the same name space into multiple files
Hey hassan, whats that device under your monitor?
Hey!
It's a CZcams subscriber counter device - it's called LaMetric
www.amazon.com/LaMetric-Time-Wi-Fi-Clock-Smart/dp/B01IVTVK3W/ref=as_li_ss_tl?ie=UTF8&qid=1490805120&sr=8-1&keywords=lametric&linkCode=sl1&tag=socialtech109-20&linkId=c529e282c3f8dfacdecbf5cc763003da
How come you prefer namespace blocks instead of top-level namespace definition?
namespace blocks are more consistent with how we scope classes, methods and everything else.
Do you have a tutorial in blazor?
I do. Here it is:
czcams.com/video/5Htj8JFglb4/video.html&ab_channel=HassanHabib
@@HassanHabib thank you sir.