Skip to content

Commit

Permalink
fix return type for FirstOrDefault (#8071)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jun 10, 2024
1 parent cbe1b52 commit d829fc2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Implementation(PhasedOperation definition, IReadOnlyList<IToken> config,
public int HandleMatch(IProcessorState processor, int bufferLength, ref int currentBufferPosition, int token)
{
IReadOnlyList<SpecializedPhase> nextPhases = _currentPhase?.Next ?? _entryPoints;
SpecializedPhase match = nextPhases.FirstOrDefault(x => x.Match == token);
SpecializedPhase? match = nextPhases.FirstOrDefault(x => x.Match == token);

if (match != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ internal IEnumerable<PackageSource> RemoveInsecurePackages(IEnumerable<PackageSo
continue;
}
atLeastOneSourceValid = true;
NugetPackageMetadata matchedVersion = foundPackages.FirstOrDefault(package => package.Identity.Version == packageVersion);
NugetPackageMetadata? matchedVersion = foundPackages.FirstOrDefault(package => package.Identity.Version == packageVersion);
if (matchedVersion != null)
{
_nugetLogger.LogDebug($"{packageIdentifier}::{packageVersion} was found in {foundSource.Source}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static HashSet<IMacroConfig> GetDependentMacros(IMacroConfig config, IRe

foreach (string dependent in macroWithDep.Dependencies)
{
IMacroConfig macro = allMacroConfigs.FirstOrDefault(mc => mc.VariableName == dependent);
IMacroConfig? macro = allMacroConfigs.FirstOrDefault(mc => mc.VariableName == dependent);
if (macro != null)
{
dependents.Add(macro);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public GlobalRunConfig GlobalOperationConfig
if (customGlobModel.ConditionResult)
{
// only add the special if the condition is true
OperationConfigDefault defaultParams = defaultSpecials.FirstOrDefault(x => x.Glob == customGlobModel.Glob);
OperationConfigDefault? defaultParams = defaultSpecials.FirstOrDefault(x => x.Glob == customGlobModel.Glob);

defaultParams ??= OperationConfigDefault.Default;

Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.TemplateEngine.Mocks/MockMountPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public IFileSystemInfo FileSystemInfo(string fullPath)

for (int i = 0; i < parts.Length; ++i)
{
IFileSystemInfo info = current.EnumerateFileSystemInfos(parts[i], SearchOption.TopDirectoryOnly).FirstOrDefault();
IFileSystemInfo? info = current.EnumerateFileSystemInfos(parts[i], SearchOption.TopDirectoryOnly).FirstOrDefault();

if (info == null)
{
Expand Down

0 comments on commit d829fc2

Please sign in to comment.