Skip to content

Fix code-generation on enumerations - #429

Merged
SteveSyfuhs merged 1 commit into
dotnet:developfrom
nhart12:develop
Oct 22, 2026
Merged

SteveSyfuhs merged 1 commit into
dotnet:developfrom
nhart12:develop

Conversation

@nhart12

@nhart12 nhart12 commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

What's the problem?

Latest version (4.6.168) gives error on NegotiationToken negoToken = NegotiationToken.Decode(incomingBlob.ToArray())
ASN1 corrupted data. Expected Integer; Actual: Enumerated

  • Bugfix
  • New Feature

What's the solution?

Try reading enumerated value if we have it instead of parsing as Integer

  • Includes unit tests
  • Requires manual test

What issue is this related to, if any?

@nhart12
nhart12 marked this pull request as draft June 5, 2026 20:48
@nhart12
nhart12 marked this pull request as ready for review September 3, 2026 20:10
@nhart12

nhart12 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@SteveSyfuhs you able to take a look here?

@SteveSyfuhs

Copy link
Copy Markdown
Collaborator

Apologies, I completely missed this when you opened it forever ago. Looks good to me. Merging.

@SteveSyfuhs
SteveSyfuhs merged commit 7e59cea into dotnet:develop Oct 22, 2026
1 check passed
@SteveSyfuhs

Copy link
Copy Markdown
Collaborator

Well that was maybe shortlived. This failed a test:

Failed NegTokenResp_EnumeratedField_RoundTrip [< 1 ms]
  Error Message:
   Test method Tests.Kerberos.NET.SourceGenerator.GeneratedRoundtripTests.NegTokenResp_EnumeratedField_RoundTrip threw exception: 
System.Security.Cryptography.CryptographicException: ASN1 corrupted data. Expected Enumerated; Actual: Integer
  Stack Trace:
      at System.Security.Cryptography.Asn1.AsnReader.TryReadSignedInteger(Int32 sizeLimit, Asn1Tag expectedTag, UniversalTagNumber tagNumber, Int64& value) in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\Asn1\Experimental\AsnReader.Integer.cs:line 641
   at System.Security.Cryptography.Asn1.AsnReader.ReadEnumeratedValue(Asn1Tag expectedTag, Type tEnum) in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\Asn1\Experimental\AsnReader.Enumerated.cs:line 206
   at System.Security.Cryptography.Asn1.AsnReader.ReadEnumeratedValue(Type tEnum) in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\Asn1\Experimental\AsnReader.Enumerated.cs:line 150
   at System.Security.Cryptography.Asn1.AsnReader.ReadEnumeratedValue[TEnum]() in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\Asn1\Experimental\AsnReader.Enumerated.cs:line 87
   at Kerberos.NET.Entities.NegTokenResp.Decode[T](AsnReader reader, Asn1Tag expectedTag, T& decoded) in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\obj\Release\netstandard2.0\Kerberos.NET.Asn1SourceGenerator\Kerberos.NET.Asn1SourceGenerator.Asn1IncrementalGenerator\NegTokenResp.g.cs:line 164
   at Kerberos.NET.Entities.NegTokenResp.Decode(Asn1Tag expectedTag, ReadOnlyMemory`1 encoded, AsnEncodingRules ruleSet) in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\obj\Release\netstandard2.0\Kerberos.NET.Asn1SourceGenerator\Kerberos.NET.Asn1SourceGenerator.Asn1IncrementalGenerator\NegTokenResp.g.cs:line 131
   at Kerberos.NET.Entities.NegTokenResp.Decode(ReadOnlyMemory`1 encoded, AsnEncodingRules ruleSet) in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\obj\Release\netstandard2.0\Kerberos.NET.Asn1SourceGenerator\Kerberos.NET.Asn1SourceGenerator.Asn1IncrementalGenerator\NegTokenResp.g.cs:line 115
   at Kerberos.NET.Entities.NegTokenResp.Decode(ReadOnlyMemory`1 data) in D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET\obj\Release\netstandard2.0\Kerberos.NET.Asn1SourceGenerator\Kerberos.NET.Asn1SourceGenerator.Asn1IncrementalGenerator\NegTokenResp.g.cs:line 110
   at Tests.Kerberos.NET.SourceGenerator.GeneratedRoundtripTests.NegTokenResp_EnumeratedField_RoundTrip() in D:\a\Kerberos.NET\Kerberos.NET\Tests\Tests.Kerberos.NET\SourceGenerator\GeneratedRoundtripTests.cs:line 395
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

  Passed NegTokenResp_NullState_StillEncodes [< 1 ms]

Test Run Failed.
Total tests: 541
     Passed: 539
     Failed: 2
 Total time: 19.9912 Seconds
     1>Project "D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET.sln" (1) is building "D:\a\Kerberos.NET\Kerberos.NET\Tests\Tests.Kerberos.NET\Tests.Kerberos.NET.csproj" (3) on node 4 (VSTest target(s)).
     3>_VSTestConsole:
         MSB4181: The "VSTestTask" task returned false but did not log an error.
     3>Done Building Project "D:\a\Kerberos.NET\Kerberos.NET\Tests\Tests.Kerberos.NET\Tests.Kerberos.NET.csproj" (VSTest target(s)) -- FAILED.
     1>Done Building Project "D:\a\Kerberos.NET\Kerberos.NET\Kerberos.NET.sln" (VSTest target(s)) -- FAILED.

@nhart12

nhart12 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Yes, sorry about that. I forgot to account for the encoding side of the equation.
Opened #439

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

Successfully merging this pull request may close these issues.

2 participants