Closed
Description
When I run the baseline package validation on a library that contains the following C# code that was not changed between the two versions
public abstract partial class IdentifierBase
{
protected const string PermissiveNamePattern = @"^(?!\p{Z})[\p{L}\p{M}\p{N}\p{P}\p{S} ]{1,1024}(?<!\p{Z})$";
// ...
[GeneratedRegex(PermissiveNamePattern)]
protected static partial Regex PermissiveNameRegex();
}
I get the following error that I think shouldn't be getting:
C:\Program Files\dotnet\sdk\8.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error : API compatibility errors between 'lib/net8.0/MyLib.dll' (C:\Users\bitbonk\.nuget\packages\MyLib\1.1.0\MyLib.1.1.0.nupkg) and 'lib/net8.0/MyLib.dll' (C:\source\repos\MySolution\src\MyLib\bin\Release\MyLib.1.2.0.nupkg):
C:\Program Files\dotnet\sdk\8.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0015: Cannot change arguments of attribute 'System.CodeDom.Compiler.GeneratedCodeAttribute' on 'MyLib.IdentifierBase.PermissiveNameRegex()'.
When I look at the IL using ILDASM, I see no differences in the GeneratedCodeAttribute
Decompiled IL in MyLib.dll Version 1.1.0:
.method family hidebysig static class [System.Text.RegularExpressions]System.Text.RegularExpressions.Regex
PermissiveNameRegex() cil managed
{
.custom instance void [System.Text.RegularExpressions]System.Text.RegularExpressions.GeneratedRegexAttribute::.ctor(string) = ( 01 00 39 5E 28 3F 21 5C 70 7B 5A 7D 29 5B 5C 70 // ..9^(?!\p{Z})[\p
7B 4C 7D 5C 70 7B 4D 7D 5C 70 7B 4E 7D 5C 70 7B // {L}\p{M}\p{N}\p{
50 7D 5C 70 7B 53 7D 20 5D 7B 31 2C 31 30 32 34 // P}\p{S} ]{1,1024
7D 28 3F 3C 21 5C 70 7B 5A 7D 29 24 00 00 ) // }(?<!\p{Z})$..
.custom instance void [System.Runtime]System.CodeDom.Compiler.GeneratedCodeAttribute::.ctor(string,
string) = ( 01 00 28 53 79 73 74 65 6D 2E 54 65 78 74 2E 52 // ..(System.Text.R
65 67 75 6C 61 72 45 78 70 72 65 73 73 69 6F 6E // egularExpression
73 2E 47 65 6E 65 72 61 74 6F 72 0C 38 2E 30 2E // s.Generator.8.0.
31 30 2E 33 36 36 31 32 00 00 ) // 10.36612..
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld class System.Text.RegularExpressions.Generated.'<RegexGenerator_g>F36B3EC1E1E4EB76C6E665E6A813463B838EF06AE647BC127D891E46EBC83B058__PermissiveNameRegex_5' System.Text.RegularExpressions.Generated.'<RegexGenerator_g>F36B3EC1E1E4EB76C6E665E6A813463B838EF06AE647BC127D891E46EBC83B058__PermissiveNameRegex_5'::Instance
IL_0005: ret
} // end of method IdentifierBase::PermissiveNameRegex
Decompiled IL in MyLib.dll Version 1.2.0:
.method family hidebysig static class [System.Text.RegularExpressions]System.Text.RegularExpressions.Regex
PermissiveNameRegex() cil managed
{
.custom instance void [System.Text.RegularExpressions]System.Text.RegularExpressions.GeneratedRegexAttribute::.ctor(string) = ( 01 00 39 5E 28 3F 21 5C 70 7B 5A 7D 29 5B 5C 70 // ..9^(?!\p{Z})[\p
7B 4C 7D 5C 70 7B 4D 7D 5C 70 7B 4E 7D 5C 70 7B // {L}\p{M}\p{N}\p{
50 7D 5C 70 7B 53 7D 20 5D 7B 31 2C 31 30 32 34 // P}\p{S} ]{1,1024
7D 28 3F 3C 21 5C 70 7B 5A 7D 29 24 00 00 ) // }(?<!\p{Z})$..
.custom instance void [System.Runtime]System.CodeDom.Compiler.GeneratedCodeAttribute::.ctor(string,
string) = ( 01 00 28 53 79 73 74 65 6D 2E 54 65 78 74 2E 52 // ..(System.Text.R
65 67 75 6C 61 72 45 78 70 72 65 73 73 69 6F 6E // egularExpression
73 2E 47 65 6E 65 72 61 74 6F 72 0C 38 2E 30 2E // s.Generator.8.0.
31 30 2E 33 36 36 31 32 00 00 ) // 10.36612..
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld class System.Text.RegularExpressions.Generated.'<RegexGenerator_g>F6DAE5A16EF3D26D2EC7365C0E21EC5F0F0BC7D5BF6DD551DA7C930B1A38CDA6C__PermissiveNameRegex_5' System.Text.RegularExpressions.Generated.'<RegexGenerator_g>F6DAE5A16EF3D26D2EC7365C0E21EC5F0F0BC7D5BF6DD551DA7C930B1A38CDA6C__PermissiveNameRegex_5'::Instance
IL_0005: ret
} // end of method IdentifierBase::PermissiveNameRegex