VerifyTests / Verify.QuestPDF

Extends Verify to allow verification of documents via QuestPDF.
MIT License
13 stars 3 forks source link

"System.MissingMethodException" when using VerifyQuestPDF on IDocument #119

Closed Burgyn closed 1 year ago

Burgyn commented 1 year ago

Preamble

I've encountered a System.MissingMethodException while using VerifyQuestPDF for verifying IDocument. I've made sure to replicate the bug with a minimal reproducible example, which I'll link below. My development environment is up to date.

Describe the bug

When I use VerifyQuestPDF to verify an IDocument, I receive the following exception:

System.MissingMethodException : Method not found: 'System.Collections.Generic.IEnumerable`1<Byte[]> QuestPDF.Fluent.GenerateExtensions.GenerateImages(QuestPDF.Infrastructure.IDocument)'.

Stacktrace

[xUnit.net 00:00:01.71]     GenerateQuestPDF.Tests.PdfGenerator.Test1 [FAIL]
  Failed GenerateQuestPDF.Tests.PdfGenerator.Test1 [949 ms]
  Error Message:
   System.MissingMethodException : Method not found: 'System.Collections.Generic.IEnumerable`1<Byte[]> QuestPDF.Fluent.GenerateExtensions.GenerateImages(QuestPDF.Infrastructure.IDocument)'.
  Stack Trace:
     at VerifyTests.VerifyQuestPdf.<>c.<Initialize>b__4_1(IDocument document, IReadOnlyDictionary`2 settings)
   at VerifyTests.VerifierSettings.<>c__DisplayClass152_0`1.<RegisterFileConverter>b__0(T o, IReadOnlyDictionary`2 context) in /_/src/Verify/Splitters/Settings_Typed.cs:line 29
   at VerifyTests.VerifierSettings.<>c__DisplayClass153_0`1.<RegisterFileConverter>b__0(Object o, IReadOnlyDictionary`2 context) in /_/src/Verify/Splitters/Settings_Typed.cs:line 38
   at VerifyTests.InnerVerifier.Verify(Object target) in /_/src/Verify/Verifier/InnerVerifier_Object.cs:line 67
   at VerifyXunit.Verifier.<>c__DisplayClass8_0.<<Verify>b__0>d.MoveNext() in /_/src/Verify.Xunit/Verifier.cs:line 76
--- End of stack trace from previous location ---
--- End of stack trace from previous location ---

Expected Behavior:

I expected the PDF verification to complete successfully without any exceptions.

Version Information:

.NET: 7 Verify.QuestPDF: 2.2.0 QuestPDF: 2023.9.1

Minimal Repro

I have prepared a minimal reproduction example based on the demo provided by VerifyTests/Verify.QuestPDF. The repro has two projects:

GenerateQuestPDF: Contains the PdfGenerator class. GenerateQuestPDF.Tests: Contains the test. Link to the reproducible example on GitHub

Submit a PR that fixes the bug

I haven't found a solution to the bug yet.

SimonCropp commented 1 year ago

can u try 2.2.1

MO2k4 commented 1 year ago

I think i receive something similiar:

System.MissingMethodException : Method not found: 'Void QuestPDF.Fluent.ElementExtensions.Element(!!0, System.Action`1)' with 2.2.1 and QuestPDF 2022.12.7

Burgyn commented 1 year ago

Hi @SimonCropp,

thanks a lot. In 2.2.1 is fixed.

MO2k4 commented 1 year ago

@SimonCropp Should i create a minimal repo or are u able to reproduce this?

SimonCropp commented 1 year ago

@MO2k4 yes please

MO2k4 commented 1 year ago

@SimonCropp https://github.com/MO2k4/Sample.VerifyQuestPdf here it is if i can do anything from my end, just ping me

thank u for looking into this :)

SimonCropp commented 1 year ago

@MO2k4 can u try 2.2.2

MO2k4 commented 1 year ago

@SimonCropp it does work with the latest quest pdf version 🥳

harvinders commented 6 months ago

@SimonCropp Started to get the error when I updated to QuestPdf 2024.3.2 and Verify.QuestPdf 2.2.2.

 Tests.PdfGenerationTests.When_none_of_the_step_results_have_certificate_visibility_the_subresults_grid_is_not_displayed(fileName: "6", input: "Stage1(03/07/2022)  Source: PdfGenerationTests.cs line 111  Duration: 673 ms

Message:  System.MissingMethodException : Method not found: 'System.DateTime QuestPDF.Infrastructure.DocumentMetadata.get_CreationDate()'.

Stack Trace:  DocumentMetadataConverter.Write(VerifyJsonWriter writer, DocumentMetadata value) WriteOnlyJsonConverter`1.Write(VerifyJsonWriter writer, Object value) line 7 WriteOnlyJsonConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) line 12 JsonSerializerInternalWriter.SerializeConvertible(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty) line 545 JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) line 116 JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) line 398 JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) line 123 JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type type) line 30 JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type type) line 619 JsonSerializer.Serialize(JsonWriter jsonWriter, Object value) line 585

<6 more frames...> JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type type) line 30 JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type type) line 619 JsonSerializer.Serialize(JsonWriter jsonWriter, Object value) line 585 JsonFormatter.AsJson(VerifySettings settings, Counter counter, Object value) line 7 InnerVerifier.TryGetRootTarget(Object root, Nullable`1& target) line 140 InnerVerifier.VerifyInner(Object root, Func`1 cleanup, IEnumerable`1 targets, Boolean doExpressionConversion) line 11 InnerVerifier.Verify(Object target) line 68 <b__0>d.MoveNext() line 76 --- End of stack trace from previous location --- --- End of stack trace from previous location ---
SimonCropp commented 6 months ago

hmm. looks like a breaking change in QuestPDF. i will update all the refs and push a new version.

give me 15

harvinders commented 6 months ago

Thanks @SimonCropp , the issue is fixed