@@ -53,7 +53,7 @@ public class Bundle
5353 /// The entries with these names are only resolved with <see cref="ReadSource.Bundle"/>.
5454 /// This feature is only designed to prevent accidental modification of important files.
5555 /// </remarks>
56- protected List < string > ProtectedEntryNames { get ; private set ; } =
56+ protected HashSet < string > ProtectedEntryNames { get ; private set ; } =
5757 [
5858 ".manifest.ec" ,
5959 ".signatures.ec" ,
@@ -330,7 +330,7 @@ protected virtual void Parse(ZipArchive zip)
330330 Logger . LogDebug ( "Parsing manifest" ) ;
331331 Manifest = JsonSerializer . Deserialize ( entry . Open ( ) , typeof ( Manifest ) , SourceGenerationManifestContext . Default ) as Manifest ?? new Manifest ( ) ;
332332
333- List < string > protectedEntries = ProtectedEntryNames . Union ( Manifest . ProtectedEntryNames ) . ToList ( ) ;
333+ HashSet < string > protectedEntries = ProtectedEntryNames . Union ( Manifest . ProtectedEntryNames ) . ToHashSet ( ) ;
334334 ProtectedEntryNames = protectedEntries ;
335335 Manifest . ProtectedEntryNames = protectedEntries ;
336336 }
@@ -447,6 +447,9 @@ public void Sign(X509Certificate2 certificate, RSA privateKey)
447447 byte [ ] certData = certificate . Export ( X509ContentType . Cert ) ;
448448 string name = certificate . GetCertHashString ( ) ;
449449
450+ Logger . LogDebug ( "Adding entry name: {name} to protected entry names" , name ) ;
451+ ProtectedEntryNames . Add ( name ) ;
452+
450453 Logger . LogDebug ( "Signing manifest" ) ;
451454 byte [ ] manifestData = GetManifestData ( ) ;
452455 byte [ ] signature = privateKey . SignData ( manifestData , HashAlgorithmName . SHA512 , RSASignaturePadding . Pkcs1 ) ;
@@ -785,6 +788,7 @@ private void ProcessPendingFiles(ZipArchive zip)
785788 protected virtual byte [ ] GetManifestData ( )
786789 {
787790 Manifest . UpdatedBy = GetType ( ) . FullName ;
791+ Manifest . ProtectedEntryNames = ProtectedEntryNames . Union ( Manifest . ProtectedEntryNames ) . ToHashSet ( ) ;
788792
789793 return Export ( Manifest , SourceGenerationManifestContext . Default ) ;
790794 }
0 commit comments