Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to prevent certain references from being included on a project?

Tags:

Basically I want to do some preventative maintenance. There are certain 3rd party libraries that I'd like to prevent being included as references in a certain project. Is there any way you can specify which references are prohibited for a project?

EDIT: I'll clarify the purpose a bit. The project I want to protect is a class library that I want to have functionality from a very specific set of 3rd party libraries. The class library is used in other solutions for common data access functionality so if those 3rd party libraries were referenced, they would be needed as well. The aim is to keep that one project just a data access library and keep the "package" lightweight.

EDIT2: Not sure why the down votes. Was a question out of interest in whether this sort of thing could be done.

like image 555
Shiv Avatar asked Jun 21 '13 01:06

Shiv


People also ask

How do I manage references in Visual Studio?

Restart Visual Studio, create a new C# UWP app project, and then right-click on the project and choose Add Reference. Go to the Windows tab, then the Extensions sub-tab, and select the Extension SDK. Look at the right pane in the Reference Manager. If it has dependencies, they will be listed there.

What are references for a project?

A reference project is a write-protected copy of a project at a particular time.

How do I resolve a reference problem in Visual Studio?

To fix a broken project reference by correcting the reference path. In Solution Explorer, right-click your project node, and then select Properties. The Project Designer appears. If you're using Visual Basic, select the References page, and then click the Reference Paths button.


1 Answers

Despite the downvotes, I find this a legitimate question. I work in a large development team, all working on the same software, and have a similar issue.

We work in a large Domain Driven Design architecture with many different bounded contexts and don't want to people to add references between the contexts. We have guidelines, standards, architecture documents, code reviews etc, lots of things which prevent references of being added IRL (as somebody put it). However, we had two relatively new starters who haven't got much experience with the current structure and just don't magically know everything. They happened to review each others code and voila, the unwanted reference is added.

I see nothing draconian in trying to prevent mistakes from happening and making sure standards are adhered to. Just a precautionary measure. Isn't that partially why we are writing unit tests, too? So that some other, new guys in the future can be made aware that they unknowingly broke something?

I don't particularly like analysing the project file for the references. The way we'll probably handle it is to define a set of unit tests which crawl through the assembly references of every project under test and fail when they identify references which aren't supposed to be there. Obviously that only works if you have continuous integration / deployment including running the unit tests.

So even if the new guys check in some stuff without running the unit tests locally first (and realising their mistake), our bright red blinking build status light or the build server emails will soon tell everybody on the team what has gone wrong.

like image 189
Ben Avatar answered Sep 29 '22 18:09

Ben