Merged PR 584959: Update csc to 3.7.0 and fix nullability warnings

This is the second PR that is required to make the final PR for adding .net5 support simpler.

The PR updates the compiler to a 3.7 version (this version does not support C# 9 yet), and fixes a bunch of nullability warnings that appear after the upgrade to 3.7 and some of them will be visible only when targeting .net 5.

This is another low risk PR.
This commit is contained in:
Sergey Tepliakov 2020-11-13 23:31:25 +00:00
Родитель 986645349a
Коммит d95dcc758e
65 изменённых файлов: 138 добавлений и 77 удалений

Просмотреть файл

@ -132,7 +132,9 @@ namespace BuildXL.Cache.ContentStore.App.Test
if (!serviceProcess.HasExited)
{
serviceProcess.Kill();
#pragma warning disable AsyncFixer02 // WaitForExitAsync should be used instead
serviceProcess.WaitForExit();
#pragma warning restore AsyncFixer02
}
}
}
@ -165,7 +167,9 @@ namespace BuildXL.Cache.ContentStore.App.Test
var result = await Task.Run(() =>
{
#pragma warning disable AsyncFixer02 // WaitForExitAsync should be used instead
process.WaitForExit();
#pragma warning restore AsyncFixer02
return process.ExitCode;
});

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using BuildXL.Cache.ContentStore.Distributed.NuCache;
using BuildXL.Cache.ContentStore.Hashing;
@ -72,7 +73,7 @@ namespace BuildXL.Cache.ContentStore.Distributed
}
/// <inheritdoc />
public bool Equals(ContentHashWithSizeAndLocations other)
public bool Equals([AllowNull]ContentHashWithSizeAndLocations other)
{
if (other is null)
{
@ -84,7 +85,7 @@ namespace BuildXL.Cache.ContentStore.Distributed
return true;
}
return Locations.SequenceEqual(other.Locations) && ContentHash.Equals(other.ContentHash) && Size == other.Size;
return Locations!.SequenceEqual(other.Locations!) && ContentHash.Equals(other.ContentHash) && Size == other.Size;
}
/// <inheritdoc />

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using BuildXL.Cache.ContentStore.Hashing;
@ -617,8 +618,10 @@ namespace BuildXL.Cache.ContentStore.Distributed.NuCache
private class Comparer : IComparer<MachineWithBinAssignments>
{
public int Compare(MachineWithBinAssignments x, MachineWithBinAssignments y)
public int Compare([AllowNull]MachineWithBinAssignments x, [AllowNull]MachineWithBinAssignments y)
{
Contract.Requires(x != null);
Contract.Requires(y != null);
return x.BinsAssignedTo.Count != y.BinsAssignedTo.Count
? x.BinsAssignedTo.Count.CompareTo(y.BinsAssignedTo.Count)
: x.MachineId.Index.CompareTo(y.MachineId.Index);

Просмотреть файл

@ -165,7 +165,7 @@ namespace BuildXL.Cache.ContentStore.Distributed.NuCache
return new Result<MachineLocation[]>(locationsResult);
}
return locationsResult.Value
return locationsResult.Value!
.Where(machineId => !_inactiveMachinesSet[machineId] && !_closedMachinesSet[machineId])
.Select(id => _locationByIdMap[id.Index])
.ToArray();

Просмотреть файл

@ -321,8 +321,8 @@ namespace BuildXL.Cache.ContentStore.Distributed.NuCache
var result = await _locationStore.GetBulkAsync(context, new[] { hash, startedCopyHash }).ThrowIfFailure();
var info = result.ContentHashesInfo[0];
var startedCopyLocations = result.ContentHashesInfo[1].Locations;
var finishedCopyLocations = info.Locations;
var startedCopyLocations = result.ContentHashesInfo[1].Locations!;
var finishedCopyLocations = info.Locations!;
var pendingCopies = startedCopyLocations.Except(finishedCopyLocations).Count();
return (new ContentHashWithSizeAndLocations(info.ContentHash, info.Size, TranslateLocations(info.Locations!)), pendingCopies);

Просмотреть файл

@ -1311,7 +1311,7 @@ namespace BuildXL.Cache.ContentStore.Distributed.Sessions
// A machine in the build may be a designated location for the hash,
// but we won't pushing to the same machine twice, because 'replicatedLocations' argument
// has a local machine that we're about to push for inside the ring copy.
var candidates = designatedLocationsResult.Value
var candidates = designatedLocationsResult.Value!
.Except(replicatedLocations).ToArray();
if (candidates.Length > 0)

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
using System.Diagnostics.CodeAnalysis;
#pragma warning disable CS3001 // CLS
#pragma warning disable CS3003
@ -46,7 +47,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc/>
public bool Equals(ChunkInfo other)
public bool Equals([AllowNull]ChunkInfo other)
{
return Offset == other.Offset && Size == other.Size && ByteArrayComparer.ArraysEqual(Hash, other.Hash);
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
using BuildXL.Cache.ContentStore.UtilitiesCore;
@ -212,7 +213,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public bool Equals(ContentHash other)
public bool Equals([AllowNull]ContentHash other)
{
return _bytes.Equals(other._bytes) && ((int)_hashType).Equals((int)other._hashType);
}
@ -231,7 +232,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public int CompareTo(ContentHash other)
public int CompareTo([MaybeNull]ContentHash other)
{
var compare = _bytes.CompareTo(other._bytes);
return compare != 0 ? compare : ((int)_hashType).CompareTo((int)other._hashType);

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Diagnostics;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Security.Cryptography;
using System.Threading;
@ -120,7 +121,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
} while (bytesJustRead > 0);
hasher.TransformFinalBlock(buffer, 0, 0);
var hashBytes = hasher.Hash;
var hashBytes = hasher.Hash!;
// Retrieve the DedupNode before losing the hasher token.
switch (Info.HashType)
@ -420,7 +421,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object? state)
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, [AllowNull]AsyncCallback callback, object? state)
{
throw new NotImplementedException();
}
@ -446,7 +447,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
var handle = Buffer.GetBuffer();
handle.Value.CopyFrom(buffer, offset, count);
return _hashingBufferBlock.SendAsync(handle);
return _hashingBufferBlock!.SendAsync(handle);
}
else
{
@ -488,7 +489,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object? state)
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, [AllowNull]AsyncCallback callback, object? state)
{
throw new NotImplementedException();
}
@ -571,7 +572,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
{
_ownerStream.ThrowIfDisposed();
Contract.Assert(Finalized);
return _hasherToken.Hasher.Hash;
return _hasherToken.Hasher.Hash!;
}
}
}

Просмотреть файл

@ -17,7 +17,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
private readonly SHA512 _hasher = new SHA512CryptoServiceProvider();
/// <inheritdoc />
public override byte[] Hash => TruncateTo256Bits(base.Hash);
public override byte[] Hash => TruncateTo256Bits(base.Hash!);
/// <inheritdoc />
public override int HashSize => 8 * DedupSingleChunkHashInfo.Length;
@ -43,7 +43,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
protected override byte[] HashFinal()
{
_hasher.TransformFinalBlock(EmptyArray, 0, 0);
return TruncateTo256Bits(_hasher.Hash);
return TruncateTo256Bits(_hasher.Hash!);
}
internal byte[] HashFinalInternal()

Просмотреть файл

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
@ -394,7 +395,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
{
foreach (DedupNode node in EnumerateInnerNodesDepthFirst())
{
foreach (DedupNode chunk in node.ChildNodes.Where(n => n.Type == NodeType.ChunkLeaf))
foreach (DedupNode chunk in node.ChildNodes!.Where(n => n.Type == NodeType.ChunkLeaf))
{
yield return chunk;
}
@ -427,7 +428,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc/>
public bool Equals(DedupNode other)
public bool Equals([AllowNull]DedupNode other)
{
return ByteArrayComparer.ArraysEqual(Hash, other.Hash);
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
using BuildXL.Cache.ContentStore.UtilitiesCore;
@ -139,7 +140,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public bool Equals(FixedBytes other)
public bool Equals([AllowNull]FixedBytes other)
{
byte* o = other._bytes;
fixed (byte* p = _bytes)
@ -173,7 +174,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public int CompareTo(FixedBytes other)
public int CompareTo([MaybeNull]FixedBytes other)
{
byte* o = other._bytes;
fixed (byte* p = _bytes)

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
@ -296,7 +297,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public bool Equals(MurmurHash3 other)
public bool Equals([AllowNull]MurmurHash3 other)
{
return other.High == High && other.Low == Low;
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
@ -168,7 +169,7 @@ namespace BuildXL.Cache.ContentStore.Hashing
}
/// <inheritdoc />
public bool Equals(MurmurHash3_32 other)
public bool Equals([AllowNull]MurmurHash3_32 other)
{
return other.Hash == Hash;
}

Просмотреть файл

@ -36,7 +36,8 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Extensions
var settings = new DataContractJsonSerializerSettings {UseSimpleDictionaryFormat = true};
var serializer = new DataContractJsonSerializer(typeof(T), settings);
stream.Position = 0;
return (T)serializer.ReadObject(stream);
// TODO: suppressing this for now, but the clients need to respect that the result of this method may be null.
return (T)serializer.ReadObject(stream)!;
}
/// <summary>

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
@ -302,7 +303,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.FileSystem
public string GetPathWithoutLongPathPrefix() => RemoveLongPathPrefixIfNeeded(Path);
/// <inheritdoc />
public bool Equals(AbsolutePath other)
public bool Equals([AllowNull]AbsolutePath other)
{
return base.Equals(other);
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
@ -71,7 +72,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.FileSystem
}
/// <inheritdoc />
public bool Equals(RelativePath other)
public bool Equals([AllowNull]RelativePath other)
{
return base.Equals(other);
}

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Cache.ContentStore.Interfaces.Results
{
@ -111,7 +112,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
public static implicit operator bool(CopyFileResult result) => result.Succeeded;
/// <inheritdoc />
public bool Equals(CopyFileResult other)
public bool Equals([AllowNull]CopyFileResult other)
{
return EqualsBase(other) && other != null && Code == other.Code;
}

Просмотреть файл

@ -58,7 +58,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
public readonly T Session;
/// <inheritdoc />
public bool Equals(CreateSessionResult<T> other)
public bool Equals([AllowNull]CreateSessionResult<T> other)
{
if (other is null || !base.Equals(other))
{

Просмотреть файл

@ -50,7 +50,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
public override bool Succeeded => false;
/// <inheritdoc />
public bool Equals(ErrorResult other)
public bool Equals([AllowNull]ErrorResult other)
{
return EqualsBase(other) && other != null;
}

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Cache.ContentStore.Interfaces.Results
{
@ -97,7 +98,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
public bool Exists => Code == ResultCode.FileExists;
/// <inheritdoc />
public bool Equals(FileExistenceResult other)
public bool Equals([AllowNull]FileExistenceResult? other)
{
return EqualsBase(other) && other != null && Code == other.Code;
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Cache.ContentStore.Interfaces.Results
{
@ -75,7 +76,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
public T? Data { get; }
/// <inheritdoc />
public bool Equals(ObjectResult<T> other)
public bool Equals([AllowNull]ObjectResult<T> other)
{
if (other is null || !base.Equals(other))
{

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Cache.ContentStore.Interfaces.Results
{
@ -121,7 +122,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
public override bool Succeeded => Code == ResultCode.Success;
/// <inheritdoc />
public bool Equals(PinResult other)
public bool Equals([AllowNull]PinResult other)
{
return EqualsBase(other) && other != null && Code == other.Code;
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Cache.ContentStore.Interfaces.Results
{
@ -139,7 +140,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
}
/// <inheritdoc />
public bool Equals(PlaceFileResult other)
public bool Equals([AllowNull]PlaceFileResult other)
{
return EqualsBase(other) && other != null && Code == other.Code;
}

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Diagnostics.ContractsLight;
using BuildXL.Cache.ContentStore.Hashing;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Cache.ContentStore.Interfaces.Results
{
@ -93,7 +94,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
public readonly bool ContentAlreadyExistsInCache;
/// <inheritdoc />
public bool Equals(PutResult other)
public bool Equals([AllowNull]PutResult other)
{
return
base.Equals(other)

Просмотреть файл

@ -177,7 +177,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
/// <summary>
/// Returns true if 'this' and 'other' are not succeeded and both have the same error text.
/// </summary>
protected bool ErrorEquals(ResultBase other)
protected bool ErrorEquals(ResultBase? other)
{
if (other is null)
{

Просмотреть файл

@ -78,6 +78,14 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
_result = default;
}
/// <inheritdoc />
// The following attribute allows the compiler to understand that if Succeeded is true, then Value is not null.
// This is not technically correct, because the caller can specify 'isNullAllowed: true' in the constructor,
// but this is a good enough behavior for us, because in vast majority of cases, isNullAllowed is false.
// [MemberNotNullWhen(true, nameof(Value))]
// WIP ST: this is not working with the 3.7 compiler!!
public override bool Succeeded => base.Succeeded;
/// <summary>
/// Gets the resulting value.
/// </summary>
@ -105,9 +113,9 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Results
}
/// <inheritdoc />
public bool Equals(Result<T> other)
public bool Equals([AllowNull]Result<T> other)
{
return Succeeded && other.Succeeded ? Value!.Equals(other.Value) : ErrorEquals(other);
return Succeeded && other?.Succeeded == true ? Value!.Equals(other.Value) : ErrorEquals(other);
}
/// <inheritdoc />

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
using System.Diagnostics.CodeAnalysis;
using BuildXL.Cache.ContentStore.Hashing;
using BuildXL.Cache.ContentStore.Interfaces.FileSystem;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
@ -33,7 +34,7 @@ namespace BuildXL.Cache.ContentStore.Interfaces.Sessions
}
/// <inheritdoc />
public bool Equals(ContentHashWithPath other)
public bool Equals([AllowNull]ContentHashWithPath other)
{
return Hash.Equals(other.Hash) && Path.Equals(other.Path);
}

Просмотреть файл

@ -594,6 +594,7 @@ namespace BuildXL.Cache.ContentStore.Service.Grpc
return Unit.Void;
}
Contract.Assert(store != null);
result = await store.HandlePushFileAsync(cacheContext, hash, disposableFile.Path, token);
}
@ -1044,7 +1045,7 @@ namespace BuildXL.Cache.ContentStore.Service.Grpc
_contentHash = contentHash;
}
public static PushCopyLimiter Create(Context context, ConcurrencyLimiter<ContentHash> limiter, ContentHash hash, IPushFileHandler store)
public static PushCopyLimiter Create(Context context, ConcurrencyLimiter<ContentHash> limiter, ContentHash hash, IPushFileHandler? store)
{
var (added, overTheLimit) = limiter.TryAdd(hash, respectTheLimit: true);

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Cache.ContentStore.Service.Grpc
{
@ -24,7 +25,7 @@ namespace BuildXL.Cache.ContentStore.Service.Grpc
}
/// <nodoc />
public bool Equals(GrpcCopyClientKey other)
public bool Equals([AllowNull]GrpcCopyClientKey other)
{
return string.Equals(Host, other.Host, StringComparison.InvariantCultureIgnoreCase)
&& GrpcPort == other.GrpcPort;

Просмотреть файл

@ -498,7 +498,7 @@ namespace BuildXL.Cache.ContentStore.Stores
}
/// <inheritdoc />
public bool Equals(SelfCheckState other) => string.Equals(Epoch, other.Epoch) && LastReconcileTime == other.LastReconcileTime && LastPosition.Equals(other.LastPosition);
public bool Equals([AllowNull]SelfCheckState other) => string.Equals(Epoch, other.Epoch) && LastReconcileTime == other.LastReconcileTime && LastPosition.Equals(other.LastPosition);
/// <inheritdoc />
public override bool Equals(object? obj)

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using BuildXL.Cache.ContentStore.Hashing;
namespace BuildXL.Cache.ContentStore.Stores
@ -37,6 +38,6 @@ namespace BuildXL.Cache.ContentStore.Stores
public class ByHashPayloadFromDiskComparer<T> : IComparer<PayloadFromDisk<T>>
{
/// <inheritdoc />
public int Compare(PayloadFromDisk<T> left, PayloadFromDisk<T> right) => left.Hash.CompareTo(right.Hash);
public int Compare([AllowNull]PayloadFromDisk<T> left, [AllowNull]PayloadFromDisk<T> right) => left!.Hash.CompareTo(right!.Hash);
}
}

Просмотреть файл

@ -417,7 +417,7 @@ namespace BuildXL.Cache.ContentStore.Vsts
var success = DownloadUriCache.Instance.TryGetDownloadUri(contentHash, out var preauthUri);
uri = success ? preauthUri.NotNullUri : new Uri("http://empty.com");
Directory.CreateDirectory(Directory.GetParent(path).FullName);
Directory.CreateDirectory(Directory.GetParent(path)!.FullName);
// TODO: Investigate using ManagedParallelBlobDownloader instead (bug 1365340)
await ParallelHttpDownload.Download(
@ -463,7 +463,7 @@ namespace BuildXL.Cache.ContentStore.Vsts
}
catch (StorageException storageEx) when (storageEx.InnerException is WebException webEx)
{
if (((HttpWebResponse)webEx.Response).StatusCode == HttpStatusCode.NotFound)
if (((HttpWebResponse?)webEx.Response)?.StatusCode == HttpStatusCode.NotFound)
{
return null;
}

Просмотреть файл

@ -22,6 +22,7 @@ namespace Configuration {
skipDocumentationGeneration: true,
allowUnsafeBlocks: false,
nullable: true,
internalsVisibleTo: [
"BuildXL.Cache.Host.Test"

Просмотреть файл

@ -5,6 +5,8 @@ using System;
using System.Collections.Generic;
using BuildXL.Cache.ContentStore.Interfaces.Secrets;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
/// <summary>

Просмотреть файл

@ -3,6 +3,8 @@
using System.Collections.Generic;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
public class DeploymentManifest

Просмотреть файл

@ -4,6 +4,8 @@
using System;
using System.Collections.Generic;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
public class HostParameters

Просмотреть файл

@ -15,6 +15,6 @@ namespace BuildXL.Cache.Host.Configuration
/// <summary>
/// Configure the logging behavior for the service
/// </summary>
public LoggingSettings LoggingSettings { get; set; } = null;
public LoggingSettings? LoggingSettings { get; set; } = null;
}
}

Просмотреть файл

@ -3,7 +3,7 @@
using System.Runtime.Serialization;
using BuildXL.Cache.ContentStore.Interfaces.Logging;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
[DataContract]

Просмотреть файл

@ -9,7 +9,7 @@ using BuildXL.Cache.ContentStore.Grpc;
using BuildXL.Cache.ContentStore.Interfaces.Distributed;
using BuildXL.Cache.ContentStore.Interfaces.Logging;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
/// <summary>

Просмотреть файл

@ -29,7 +29,7 @@ namespace BuildXL.Cache.Host.Configuration
{
if (result != ValidationResult.Success)
{
errorList.Add(result.ErrorMessage);
errorList.Add(result.ErrorMessage!);
}
}
}

Просмотреть файл

@ -15,6 +15,6 @@ namespace BuildXL.Cache.Host.Configuration
/// <summary>
/// Configure the logging behavior for the service
/// </summary>
public LoggingSettings LoggingSettings { get; set; } = null;
public LoggingSettings? LoggingSettings { get; set; } = null;
}
}

Просмотреть файл

@ -5,6 +5,8 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
/// <summary>

Просмотреть файл

@ -5,6 +5,8 @@ using System;
using System.Collections.Generic;
using BuildXL.Cache.ContentStore.Interfaces.FileSystem;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
/// <summary>

Просмотреть файл

@ -3,6 +3,7 @@
using System.Runtime.Serialization;
using BuildXL.Cache.ContentStore.Grpc;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{

Просмотреть файл

@ -9,6 +9,8 @@ using System.Runtime.Serialization;
using BuildXL.Cache.ContentStore.Interfaces.FileSystem;
using BuildXL.Cache.ContentStore.Interfaces.Utils;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
[DataContract]

Просмотреть файл

@ -5,6 +5,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
#nullable disable
namespace BuildXL.Cache.Host.Configuration
{
/// <summary>

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
#nullable enable
@ -21,11 +22,11 @@ namespace BuildXL.Cache.Host.Configuration
typeof(uint), typeof(float)
};
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
protected override ValidationResult IsValid([AllowNull]object value, ValidationContext validationContext)
{
if (value == null)
{
return ValidationResult.Success;
return Success;
}
// Make sure that we can handle nullable numerical types
@ -60,7 +61,7 @@ namespace BuildXL.Cache.Host.Configuration
{
return (value > _min || (_minInclusive && value == _min)) &&
(value < _max || (_maxInclusive && value == _max))
? ValidationResult.Success
? Success
: new ValidationResult($"{validationContext.DisplayName} should be in range {(_minInclusive ? "[" : "(")}{_min},{_max}{(_maxInclusive ? "]" : ")")} but its value is {value}");
}
}
@ -76,23 +77,25 @@ namespace BuildXL.Cache.Host.Configuration
_allowNull = allowNull;
}
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
protected override ValidationResult IsValid([AllowNull]object value, ValidationContext validationContext)
{
if (_allowNull && value is null)
{
return ValidationResult.Success;
return Success;
}
if (value is string s)
{
if (Enum.IsDefined(_enumType, s))
{
return ValidationResult.Success;
return Success;
}
}
return new ValidationResult($"{validationContext.DisplayName} has value '{value}', which is not a valid value for enum {_enumType.FullName}");
}
}
private static ValidationResult Success => ValidationResult.Success!;
}
}

Просмотреть файл

@ -35,7 +35,7 @@ namespace BuildXL.Cache.Monitor.Library.Notifications
{
public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return TimeSpan.Parse(reader.GetString());
return TimeSpan.Parse(reader.GetString()!);
}
public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options)

Просмотреть файл

@ -89,7 +89,7 @@ namespace BuildXL.Cache.Monitor.Library.Rules.Kusto
var examples = string.Empty;
if (!string.IsNullOrEmpty(result.Machines))
{
var machines = JsonSerializer.Deserialize<List<string>>(result.Machines);
var machines = JsonSerializer.Deserialize<List<string>>(result.Machines)!;
examples = ". Examples: " + string.Join(", ", machines.Take(_configuration.MaximumExamplesOnAlert).Select(m => $"`{m}`"));
}

Просмотреть файл

@ -129,14 +129,14 @@ namespace BuildXL.Cache.Monitor.App.Scheduling
_logger = logger;
_clock = clock;
_concurrencyBuckets = configuration.MaximumConcurrency.ToDictionary(kvp => kvp.Key, kvp => {
_concurrencyBuckets = configuration.MaximumConcurrency?.ToDictionary(kvp => kvp.Key, kvp => {
if (kvp.Value <= 0)
{
return null;
}
return new SemaphoreSlim(kvp.Value);
});
}) ?? new Dictionary<string, SemaphoreSlim?>();
_notifier = notifier;
}

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
@ -61,7 +62,7 @@ namespace BuildXL.Cache.Roxis.Common
return obj is ByteString byteString && Equals(byteString);
}
public bool Equals(ByteString other)
public bool Equals([AllowNull]ByteString other)
{
return Value.SequenceEqual(other.Value);
}

Просмотреть файл

@ -24,7 +24,7 @@ namespace Engine {
];
// Update the value of this variable if you change the version of Microsoft.Net.Compilers in config.dsc.
const microsoftNetCompilerSpec = f`${Context.getMount("FrontEnd").path}/Nuget/specs/Microsoft.Net.Compilers/3.5.0/module.config.bm`;
const microsoftNetCompilerSpec = f`${Context.getMount("FrontEnd").path}/Nuget/specs/Microsoft.Net.Compilers/3.7.0/module.config.bm`;
@@public
export const categoriesToRunInParallel = [

Просмотреть файл

@ -10,8 +10,6 @@ using BuildXL.Tracing;
using BuildXL.Utilities;
using BuildXL.Utilities.Collections;
#pragma warning disable 1591 // disabling warning about missing API documentation; TODO: Remove this line and write documentation!
namespace BuildXL.Pips.Filter
{
/// <summary>
@ -436,6 +434,7 @@ namespace BuildXL.Pips.Filter
return GetDerivedSpecificHashCode();
}
/// <nodoc />
protected static ReadOnlyHashSet<T> ParallelProcessAllOutputs<T>(
IPipFilterContext context,
Action<PipId, HashSet<T>> action,

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Utilities.Collections
{
@ -104,7 +105,7 @@ namespace BuildXL.Utilities.Collections
}
/// <inheritdoc />
public bool Equals(ArrayView<T> other)
public bool Equals([AllowNull]ArrayView<T> other)
{
return m_array == other.m_array &&
m_start == other.m_start &&

Просмотреть файл

@ -457,6 +457,7 @@ namespace BuildXL.Utilities.Collections
bool result = dictionary.TryGetValue(key, out resultingValue);
Contract.Assert(result);
Contract.Assert(resultingValue != null); // Not needed for .net5, but required for .netcore3.1
return resultingValue;
}

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
using System.Diagnostics.CodeAnalysis;
namespace BuildXL.Utilities.Collections
{
@ -63,7 +64,7 @@ namespace BuildXL.Utilities.Collections
}
/// <inheritdoc />
public bool Equals(ItemResources other)
public bool Equals([AllowNull]ItemResources other)
{
return SemaphoreIncrements == other.SemaphoreIncrements;
}

Просмотреть файл

@ -126,7 +126,8 @@ namespace BuildXL.Utilities.Collections
}
/// <inheritdoc />
public bool TryGetValue(TKey key, [NotNullWhen(true)][MaybeNull]out IReadOnlyList<TValue> multiValues)
#pragma warning disable CS8767 // Nullability fof reference types in type of parameter 'multiValues' doesn't match implicitly implemented member
public bool TryGetValue([NotNull]TKey key, [MaybeNullWhen(false)]out IReadOnlyList<TValue> multiValues)
{
if (m_backingDictionary.TryGetValue(key, out List<TValue>? mutableMultiValues))
{

Просмотреть файл

@ -5,6 +5,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace BuildXL.Utilities.Collections
@ -112,7 +113,7 @@ namespace BuildXL.Utilities.Collections
}
/// <inheritdoc />
public bool Equals(ReadOnlyArray<T> other)
public bool Equals([AllowNull]ReadOnlyArray<T> other)
{
return m_array == other.m_array;
}

Просмотреть файл

@ -5,6 +5,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.ContractsLight;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace BuildXL.Utilities.Collections
@ -220,7 +221,7 @@ namespace BuildXL.Utilities.Collections
}
/// <inheritdoc />
public bool Equals(SortedReadOnlyArray<TValue, TComparer> other)
public bool Equals([AllowNull]SortedReadOnlyArray<TValue, TComparer> other)
{
return m_array == other.m_array;
}

Просмотреть файл

@ -126,7 +126,7 @@ namespace BuildXL.Utilities
public T Value => m_value;
/// <inheritdoc />
public bool Equals(EquatableClass<T> other)
public bool Equals([AllowNull]EquatableClass<T> other)
{
return EqualityComparer<T>.Default.Equals(m_value, other.m_value);
}
@ -219,7 +219,7 @@ namespace BuildXL.Utilities
public T Value => m_value;
/// <inheritdoc />
public bool Equals(EquatableEnum<T> other)
public bool Equals([AllowNull]EquatableEnum<T> other)
{
// Though enums aren't IEquatable for some reason, there's a nonboxing specialization provided by EqualityComparer.Default
return EqualityComparer<T>.Default.Equals(m_value, other.m_value);
@ -302,7 +302,7 @@ namespace BuildXL.Utilities
}
/// <inheritdoc />
public bool Equals(StructTuple<TItem1, TItem2> other)
public bool Equals([AllowNull]StructTuple<TItem1, TItem2> other)
{
return EqualityComparer<TItem1>.Default.Equals(Item1, other.Item1) &&
EqualityComparer<TItem2>.Default.Equals(Item2, other.Item2);

Просмотреть файл

@ -62,7 +62,7 @@ namespace BuildXL.Utilities.Instrumentation.Common
}
/// <inheritdoc />
public bool Equals(Diagnostic other)
public bool Equals([AllowNull]Diagnostic other)
{
return ErrorCode == other.ErrorCode && Level == other.Level && string.Equals(Message, other.Message);
}

Просмотреть файл

@ -44,7 +44,7 @@ namespace BuildXL.Utilities.Instrumentation.Common
}
/// <inheritdoc />
public bool Equals(Location other) => string.Equals(File, other.File) && Line == other.Line && Position == other.Position;
public bool Equals([AllowNull]Location other) => string.Equals(File, other.File) && Line == other.Line && Position == other.Position;
/// <inheritdoc />
public override bool Equals(object? obj)

Просмотреть файл

@ -1347,7 +1347,7 @@
"Type": "NuGet",
"NuGet": {
"Name": "Microsoft.NETCore.Compilers",
"Version": "3.5.0"
"Version": "3.7.0"
}
}
},
@ -1437,7 +1437,7 @@
"Type": "NuGet",
"NuGet": {
"Name": "Microsoft.Net.Compilers",
"Version": "3.5.0"
"Version": "3.7.0"
}
}
},

Просмотреть файл

@ -85,8 +85,8 @@ config({
{ id: "System.Diagnostics.DiagnosticSource", version: "4.0.0-beta-23516", alias: "System.Diagnostics.DiagnosticsSource.ForEventHub"},
// Roslyn
{ id: "Microsoft.Net.Compilers", version: "3.5.0" }, // Update Public/Src/Engine/UnitTests/Engine/Test.BuildXL.Engine.dsc if you change the version of Microsoft.Net.Compilers.
{ id: "Microsoft.NETCore.Compilers", version: "3.5.0" },
{ id: "Microsoft.Net.Compilers", version: "3.7.0" }, // Update Public/Src/Engine/UnitTests/Engine/Test.BuildXL.Engine.dsc if you change the version of Microsoft.Net.Compilers.
{ id: "Microsoft.NETCore.Compilers", version: "3.7.0" },
{ id: "Microsoft.CodeAnalysis.Common", version: "3.5.0" },
{ id: "Microsoft.CodeAnalysis.CSharp", version: "3.5.0" },
{ id: "Microsoft.CodeAnalysis.VisualBasic", version: "3.5.0" },