예제 #1
0
파일: PdbWriter.cs 프로젝트: binsys/roslyn
 internal PdbLogger(bool logging)
 {
     _logging = logging;
     if (logging)
     {
         _logData = PooledBlobBuilder.GetInstance();
         _hashAlgorithm = new SHA1CryptoServiceProvider();
         Debug.Assert(_hashAlgorithm.SupportsTransform);
     }
     else
     {
         _logData = null;
         _hashAlgorithm = null;
     }
 }
예제 #2
0
 internal PdbLogger(bool logging)
 {
     _logging = logging;
     if (logging)
     {
         _logData = new BinaryWriter(MemoryStream.GetInstance());
         _hashAlgorithm = new SHA1CryptoServiceProvider();
         Debug.Assert(_hashAlgorithm.SupportsTransform);
     }
     else
     {
         _logData = default(BinaryWriter);
         _hashAlgorithm = null;
     }
 }
예제 #3
0
 internal PdbLogger(bool logging)
 {
     _logging = logging;
     if (logging)
     {
         // do not get this from pool
         // we need a fairly large buffer here (where the pool typically contains small ones)
         // and we need just one per compile session
         // pooling will be couter-productive in such scenario
         _logData = new BlobBuilder(bufferFlushLimit);
         _hashAlgorithm = new SHA1CryptoServiceProvider();
         Debug.Assert(_hashAlgorithm.SupportsTransform);
     }
     else
     {
         _logData = null;
         _hashAlgorithm = null;
     }
 }
예제 #4
0
 internal abstract ImmutableArray<byte> ComputeHash(HashAlgorithm algorithm);
예제 #5
0
        private ImmutableArray<byte> GetHash(ref ImmutableArray<byte> lazyHash, HashAlgorithm algorithm)
        {
            if (lazyHash.IsDefault)
            {
                ImmutableInterlocked.InterlockedCompareExchange(ref lazyHash, ComputeHash(algorithm), default(ImmutableArray<byte>));
            }

            return lazyHash;
        }
예제 #6
0
            internal override ImmutableArray<byte> ComputeHash(HashAlgorithm algorithm)
            {
                try
                {
                    using (var stream = _resource.DataProvider())
                    {
                        if (stream == null)
                        {
                            throw new InvalidOperationException(CodeAnalysisResources.ResourceDataProviderShouldReturnNonNullStream);
                        }

                        return ImmutableArray.CreateRange(algorithm.ComputeHash(stream));
                    }
                }
                catch (Exception ex)
                {
                    throw new ResourceException(_resource.FileName, ex);
                }
            }