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

21.2.1: get_FileVersionInfo does not have an implementation #1188

Closed
felsokning opened this issue Jan 15, 2025 · 6 comments
Closed

21.2.1: get_FileVersionInfo does not have an implementation #1188

felsokning opened this issue Jan 15, 2025 · 6 comments
Labels
state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality

Comments

@felsokning
Copy link

felsokning commented Jan 15, 2025

Describe the bug
When using dependabot to bump System.IO.Abstractions from 21.1.3 to 21.2.1, one test is now failing with:

  Error Message:
   Test method Felsökning.Tests.FileExtensionsTests.FileExtensions_ReadAllTextAsync_Succeeds threw exception: 
System.TypeLoadException: Method 'get_FileVersionInfo' in type 'System.IO.Abstractions.TestingHelpers.MockFileSystem' from assembly 'TestableIO.System.IO.Abstractions.TestingHelpers, Version=21.0.0.0, Culture=neutral, PublicKeyToken=96bf224d23c43e59' does not have an implementation.
  Stack Trace:
      at Felsökning.Tests.FileExtensionsTests.FileExtensions_ReadAllTextAsync_Succeeds()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Felsökning.Tests.FileExtensionsTests.FileExtensions_ReadAllTextAsync_Succeeds()
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

To Reproduce
Steps to reproduce the behaviour:

  1. Create a Solution with two .NET9.0 projects, one for implementation and one for test.
  2. Create a method that reads text from a file on 21.1.3 in the implementation project.
  3. Create a test that will invoke and test the method from step 1 on 21.1.3 on the test project.
  4. Use your preferred means of updating here to update the NuGet package in both projects to 21.2.1.
  5. Run your test, again, note the failure.

Expected behaviour
The test should pass because get_FileVersionInfo has an implementation.

Actual behaviour
The exception thrown can't be handled and the test is marked as failed by VSTest, which fails the entire workflow/action.

Additional context
GitHub Actions demonstrating this:

https://github.com/felsokning/Fels-kning/actions/runs/12781024412/job/35628241504
https://github.com/felsokning/Fels-kning/actions/runs/12781024412/job/35628979085

It might be related to this PR: #1177

Source Code In Question

        public static async Task<T> ReadAllTextAsync<T>(this IFile file, string filePath)
        {
            var textResult = await file.ReadAllTextAsync(filePath);
            var jsonSerializerOptions = new JsonSerializerOptions
            {
                DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
            };

            return JsonSerializer.Deserialize<T>(textResult!, jsonSerializerOptions!)!;
        }

Test Code in Question

        [TestMethod]
        public async Task FileExtensions_ReadAllTextAsync_Succeeds()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { 
                    @"/dummyFilePath", 
                    new MockFileData("{\r\n  \"by\" : \"vinnyglennon\",\r\n  \"descendants\" : 36,\r\n  \"id\" : 32649091,\r\n  \"kids\" : [ 32650627, 32652889, 32651364, 32651377, 32655335, 32652375, 32652023, 32649456, 32651630, 32649718, 32653799, 32650386, 32657988, 32650124 ],\r\n  \"score\" : 162,\r\n  \"time\" : 1661859463,\r\n  \"title\" : \"Wikipedia Recent Changes Map\",\r\n  \"type\" : \"story\",\r\n  \"url\" : \"http://rcmap.hatnote.com/#en\"\r\n}") }
            });

            var result = await fileSystem.File.ReadAllTextAsync<SampleJson>("/dummyFilePath");

            result.Should().NotBeNull();
            result.Should().BeOfType<SampleJson>();
        }
    }
@felsokning felsokning added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Jan 15, 2025
@vbreuss
Copy link
Member

vbreuss commented Jan 15, 2025

Thanks for reporting.
Are you sure that you updated the version also on the test project? It looks to me as if the interface version was updated to 21.2, but your test code still uses 21.1...

@felsokning
Copy link
Author

felsokning commented Jan 15, 2025

Yes, it's also updated in the PR from dependabot: https://github.com/felsokning/Fels-kning/pull/28/files

image

@felsokning
Copy link
Author

To elaborate what's going on:

dependabot creates a PR to update the dependencies per provider.
PR: felsokning/Fels-kning#28

When any PR is created in the repository, a github action workflow is fired-off to validate that building and testing passes.
Github Action Workflow: https://github.com/felsokning/Fels-kning/blob/main/.github/workflows/pull-request-build-and-test.yaml

There is a hard-requirement for that workflow to pass (called a check), where the PR will not/cannot be merged, without the workflow being successful.

image

@vbreuss
Copy link
Member

vbreuss commented Jan 15, 2025

I see your problem.
The reason behind it is, that System.IO.Abstractions.TestingHelpers is not updated as part of this PR.
You can either manually update the version on line 28 of Felsökning.Tests/Felsökning.Tests.csproj or update the dependabot.yml to include a group for System.IO.Abstractions, e.g.:

version: 2
updates: 
  # Enable version updates for nuget 
  - package-ecosystem: nuget
    # Look for NuGet dependency info from the `root` directory
    directory: . 
    # Check the nuget registry for updates every day (weekdays) 
    schedule: 
      interval: daily
    groups:
      system_io_abstractions:
        patterns:
          - "System.IO.Abstractions*"

@felsokning
Copy link
Author

Closing against this PR. felsokning/Fels-kning#30

@felsokning
Copy link
Author

Thanks for your help with that, @vbreuss!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

No branches or pull requests

2 participants