libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

System.Net.Http.dll 2.4.0.0 NotFound

Open ntregillus opened this issue 8 years ago • 3 comments

Reproduction steps

  1. Create a new blank WebAPI project. Note under references the System.Net.Http reference version is 4.0.0.0
  2. install any version of LibGet2Sharp (any version after 0.24.1) and note that the new System.Net.Http dll is now version 4.2.0.0
  3. add a new ms test project, and attempt to write a test against anything that requires use of a RequestMessageResult. E.G: the following for example:
            [TestMethod]
            public async Task ResponseShouldRenderCorrectly()
            {
                var moq = new Mock<IGitHubRepository>();
                var target = new Target(moq.Object);
                var dto = new DTO
                {
                    SomeField = "Nate Was Here"
                };
                var actualResponse = target.StatusCode(System.Net.HttpStatusCode.OK, dto);

                Assert.IsNotNull(actualResponse);
                Assert.IsInstanceOfType(actualResponse, typeof(ResponseMessageResult));

                var strResponse = actualResponse as ResponseMessageResult;
                Assert.AreEqual(System.Net.HttpStatusCode.OK, strResponse.Response.StatusCode);
                var actual = await strResponse?.Response?.Content.ReadAsStringAsync();
                var expected = "{\"SomeField\":\"Nate Was Here\"}";
                Assert.AreEqual(expected, actual);

            }

Expected behavior

I should be able to run the test code above to work, and i should be able to debug into the Target class used in the test.

Actual behavior

I receive a FileNotFound when looking for the System.Net.Http.dll with version 4.2.0.0 which it looks for in the BuildExtensions. That file is not reachable in my class library with my test, which is referencing the webapi project i created.

Version of LibGit2Sharp (release number or SHA1)

Version 0.42.1 works, but 0.25.0 and 0.25.2 are both causing this type of un-testable code.

Operating system(s) tested; .NET runtime tested

Windows 10, .net 4.6.1 run time.

ntregillus avatar Jun 05 '18 20:06 ntregillus

@ntregillus I tried to follow the steps you've listed, but I'm not able to repro your problem. Can you provide a sample that demonstrates the problem you're seeing?

bording avatar Jun 06 '18 00:06 bording

My test project was trying to add a reference to 4.0.0.0 of the System.Net.Http.dll since my test project was just adding a project reference.

Thinking about this now, should I add a reference to LibGit2Sharp to my test project? it seems strange that is how I can get the reference to the correct Build Extensions version of the Http dll....

Net net: its strange that I have to reference a project to get an associated dll's reference to change as well....

Thoughts?

ntregillus avatar Jun 06 '18 16:06 ntregillus

@ntregillus I haven't seen the problem you're describing yet, so it's kind of hard to suggest what you should do to fix it! If you could share a sample a project that demonstrates the problem, that would be very helpful!

In general, the problems you're describing have nothing to do with LibGit2Sharp, and are more about how .NET Standard 2.0 assemblies interact with .NET Framework assemblies, especially on versions of the framework before 4.7.1, which has integrated support for it.

bording avatar Jun 06 '18 17:06 bording