From b42098c93f3e2967209ebedbf029aa5455fca37d Mon Sep 17 00:00:00 2001 From: Kevin Jones Date: Sun, 28 Apr 2024 02:37:12 -0400 Subject: [PATCH 1/2] Ignore line endings when comparing AsnXml generated content --- .../Security/Cryptography/Asn1/AsnXml.targets | 64 +++++++++++++++---- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets b/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets index 940c73ca57237..55d5e6ab4c369 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets @@ -1,9 +1,6 @@ - <_AsnXmlDiffCmd>%24%28command -v diff%29 -q -a - <_AsnXmlDiffCmd Condition="$([MSBuild]::IsOsPlatform('windows')) == 'true'">$(SystemRoot)\System32\fc.exe /a - <_AsnXmlDiffCmd Condition="$([MSBuild]::IsOsPlatform('osx')) == 'true'">diff @@ -11,6 +8,52 @@ + + + + + + + + + + + + existingLines = File.ReadLines(ExistingFile.ItemSpec).GetEnumerator()) + using (IEnumerator generatedLines = File.ReadLines(GeneratedFile.ItemSpec).GetEnumerator()) + { + while (generatedLines.MoveNext()) + { + if (!existingLines.MoveNext()) + { + ContentsDiffer = true; + return true; + } + + if (generatedLines.Current != existingLines.Current) + { + ContentsDiffer = true; + return true; + } + } + + ContentsDiffer = existingLines.MoveNext(); + } + ]]> + + + + - - - + + + - + From 98e3c6f20ac4e0d893f7019237031c010dbd434e Mon Sep 17 00:00:00 2001 From: Kevin Jones Date: Sun, 28 Apr 2024 08:23:14 -0400 Subject: [PATCH 2/2] Code review feedback --- .../Security/Cryptography/Asn1/AsnXml.targets | 35 +++---------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets b/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets index 55d5e6ab4c369..eb285cc2cfc27 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1/AsnXml.targets @@ -18,37 +18,12 @@ - - + existingLines = File.ReadLines(ExistingFile.ItemSpec).GetEnumerator()) - using (IEnumerator generatedLines = File.ReadLines(GeneratedFile.ItemSpec).GetEnumerator()) - { - while (generatedLines.MoveNext()) - { - if (!existingLines.MoveNext()) - { - ContentsDiffer = true; - return true; - } - - if (generatedLines.Current != existingLines.Current) - { - ContentsDiffer = true; - return true; - } - } - - ContentsDiffer = existingLines.MoveNext(); - } + ContentsDiffer = !File.Exists(ExistingFile.ItemSpec) || + !File.ReadLines(ExistingFile.ItemSpec).SequenceEqual(File.ReadLines(GeneratedFile.ItemSpec)); ]]> @@ -77,10 +52,10 @@ - +