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

Do the .net standard versions of NSwag.AspNetCore need to reference System.Xml.XPath.XDocument? #3279

Closed
Numpsy opened this issue Jan 30, 2021 · 6 comments

Comments

@Numpsy
Copy link
Contributor

Numpsy commented Jan 30, 2021

Hi,

A question / observation after looking at #3268 and spending some time recently reducing package references in things, where I might be missing something obvious, but it case:

The .NETStandard (1.6 and 2.0) nuget packages for NSwag.AspNetCore reference the System.Xml.XPath.XDocument package (The .NET 4.5.1 version doesn't).

I was looking at that and wondering if the 2.0 target at least needed that reference as I thought it might be built in to that version, but then looking at the build I don't actually see it used anywhere - at least, if I remove the reference from the .csproj file then it still builds and the deps.json file produced by the build doesn't list it (which I take to mean there are no indirect references either).

So - is the reference used by something else, or could it be removed?

Thanks.

@RicoSuter
Copy link
Owner

RicoSuter commented Feb 1, 2021

I think its coming from this reference path:

NSwag => NJsonSchema => Namotion.Reflection (XML Docs reading)

So in some target frameworks it's actually needed for correct XML Docs reading.

Or isnt this referencing the packages you are talking about?

@Numpsy
Copy link
Contributor Author

Numpsy commented Feb 1, 2021

Hi,

I'm talking about the direct package reference from the NSwag.AspNetCore Nuget package:

image

The Namotion.Reflection package doesn't appear to directly depend on any separate XML packages (it only uses things from System.Xml that are built into .NET or via .NETStandard I assume?)

The MS documentation for the separate System.Xml.XPath.XDocument package that I was looking at suggested that it contains some extension methods for XDocument and such, and didn't appear be actually be called by the AspNetCore library.

@RicoSuter
Copy link
Owner

I think one of the libs use xpath via reflection i think it is xml docs) and having it here loads it in some scenarios which would otherwise fail. Whats the problem with that?

@Numpsy
Copy link
Contributor Author

Numpsy commented Feb 4, 2021

Not a problem as such, just a thought that came out of me spending time recently trying to reduce package dependencies in things and trying to reduce transient package references to old versions of System.Text.RegularExpressions, which Whitesource likes to moan about.

I hadn't considered reflection based calls (though removing the reference didn't cause any unit test failures when I tried it locally), but that's why I opened a question instead of a PR.

@RicoSuter
Copy link
Owner

RicoSuter commented Feb 4, 2021

I hadn't considered reflection based calls (though removing the reference didn't cause any unit test failures when I tried it locally), but that's why I opened a question instead of a PR.

I think for .NET Core > 2 there is no problem, it's more for for legacy runtimes where this might be needed (if I remember correctly).

@Numpsy
Copy link
Contributor Author

Numpsy commented Apr 12, 2021

It looks like #3366 has removed both System.Xml.XPath.XDocument and System.IO.FileSystem as dependencies in .NETCore 3.1 and .NET 5.0 consumers, which seems a reasonable approach to tidying up newer targets without risking breaking anything in older Core targets, so I'll close this one now

@Numpsy Numpsy closed this as completed Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants