Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency on System.Xml.Linq #79

Closed
abatishchev opened this issue Mar 12, 2014 · 21 comments
Closed

Add dependency on System.Xml.Linq #79

abatishchev opened this issue Mar 12, 2014 · 21 comments
Assignees
Labels
Milestone

Comments

@abatishchev
Copy link
Contributor

Currently FluentAssertions.dll is tightly dependent on System.Xml.Linq.dll. Its unreferencing causes a compiler error:

The type 'XDocument' is required here and is unavailable. You must add a reference to assembly 'System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Please consider re-designing to remove such necessity..

@dennisdoomen
Copy link
Member

That's because it offers specific assertions for XML types. But what's your problem with its dependency?

@abatishchev
Copy link
Contributor Author

I understand the reason.
But my point this is not a usual library design approach. Usually libraries have no such dependency,
I don't have real problem with this but I don't like reference what I don't need because don't use it. Here I don't use XElement assertions but have to reference both System.Xml.dll and System.Xml.Linq.dll still.

@dennisdoomen
Copy link
Member

But that would mean splitting off the XML stuff into a dedicated assembly. However, I still don't see why this is such a big deal for you. Isn't it just a unit test project? It's not like you're going to ship that project, aren't you?

@comecme
Copy link

comecme commented Dec 13, 2019

If FluentAssertions has this dependency, why doesn't the NuGet-package show this as a dependency?

@dennisdoomen
Copy link
Member

It's something from the past.

@comecme
Copy link

comecme commented Dec 13, 2019

What do you mean?

  1. It the need for System.Xml.Linq something from the past?
  2. It the fact that the dependencies is not present in the NuGet package from the past?

I created a new Unit Test Project (.NET Framework) in VS2019, added FluentAssertions, and tried to use it, but I had to manually add System.Xml.Linq using NuGet Package Manager.

Ah, but if I create a new MSTest Test Project (.NET Core) I do not have to ad System.Xml.Linq. I suppose that is what you mean by "something from the past" then.

I think the NuGet package should have a dependency on System.Xml.Linq for its .NETFramework v4.7 and v4.5 targets.

@dennisdoomen
Copy link
Member

Yeah, you're right. Somehow we lost that dependency.

@comecme
Copy link

comecme commented Dec 15, 2019

Thanks for reopening the issue, but technically, the issue I mentioned is not the same as this issue. You still won't remove the dependency on System.Xml.Linq, but you will (re)add it to the package.

@dennisdoomen dennisdoomen changed the title Remove dependency on System.Xml.Linq Add dependency on System.Xml.Linq Dec 17, 2019
@dennisdoomen
Copy link
Member

You're right @comecme.

@FlavioGoncalves-Cayas
Copy link

Version 5.6.0 seems to be the most recent version, which includes the dependency on System.Xml.Linq. So downgrading is a temporary solution.

@comecme
Copy link

comecme commented Dec 20, 2019

I don't understand what you mean. Version 5.6.0 is not the most recent version (5.9.0 is the most recent). Also, version 5.6.0 only has no dependencies for .NETFramework,Version=v4.7.

@jnyrup
Copy link
Member

jnyrup commented Dec 20, 2019

I'm the offender #1009 .

@julealgon
Copy link

Noticed this problem while creating a few brand new projects on the full framework. We have this habit of sending a commit for the project creation, and then adding the tests later. Immediately when trying to add the tests, we'd be hit with the requirement to then add System.Xml and System.Xml.Linq.

What's the status on this one?

I tend to agree with @abatishchev and would prefer a separate FluentAssertions.Xml package here, and then remove the dependency on the main one. These libraries should be as clean as possible in regards to their dependencies.

@dennisdoomen dennisdoomen self-assigned this Jan 1, 2020
@dennisdoomen
Copy link
Member

This has been fixed on master just a minute ago.

@comecme
Copy link

comecme commented Feb 5, 2020

I did not have time to try it yet, but it does not seem to be fixed. Or not completely.

If I install version 5.10.0 into a .NET 4.7.1 Framework unit test project, no dependencies are installed.

When I use Should() I no longer get a message telling me I need to reference System.Xml.Linq. apparently this reference is automatically added (even thoug it is not listed as a dependency by NuGet Package Manager).
So far so good...

But I do get a message telling me I need to install System.Xml.

CS0012	The type 'XmlNode' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

@dennisdoomen
Copy link
Member

Ah, so we also need to add System.Xml as well.

@dennisdoomen
Copy link
Member

Fixed in 5.10.1

@braydie
Copy link

braydie commented Sep 22, 2022

Hey, I encountered this issue in v6 - I've downgraded to 5.10.3 and it seems to be working OK for me now

@dennisdoomen
Copy link
Member

dennisdoomen commented Sep 22, 2022

Hey, I encountered this issue in v6 - I've downgraded to 5.10.3 and it seems to be working OK for me now

Why would you downgrade? You can always add the missing dependency. Is there any? Which target framework are you using?

@harvzor
Copy link

harvzor commented Nov 29, 2022

Discovered this issue on version 6.6.0 and 6.8.0. The error is:

The type 'XDocument' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml.XDocument, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

My project is using dotnet 6.0.

Strange that it's asking me to use System.Xml.XDocument v6.0.0 as the latest version is 4.3.0 https://www.nuget.org/packages/System.Xml.XDocument/ 😅

@jnyrup
Copy link
Member

jnyrup commented Nov 29, 2022

@harvzor Can you share your .csproj file or even better a minimal csproj reproducing this?

It sounds a bit like an outdated nuget package manager or IDE that does not correctly know about net6 (the one released ~1 year ago) and thinks is some .net framework 6.0 (which does not exists.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants