internal PdbLogger(bool logging) { _logging = logging; if (logging) { _logData = PooledBlobBuilder.GetInstance(); _hashAlgorithm = new SHA1CryptoServiceProvider(); Debug.Assert(_hashAlgorithm.SupportsTransform); } else { _logData = null; _hashAlgorithm = null; } }
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; } }
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; } }
internal abstract ImmutableArray<byte> ComputeHash(HashAlgorithm algorithm);
private ImmutableArray<byte> GetHash(ref ImmutableArray<byte> lazyHash, HashAlgorithm algorithm) { if (lazyHash.IsDefault) { ImmutableInterlocked.InterlockedCompareExchange(ref lazyHash, ComputeHash(algorithm), default(ImmutableArray<byte>)); } return lazyHash; }
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); } }