Skip to content

Commit

Permalink
Handling of potential null version values
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Messing <141575989+timmyteo@users.noreply.github.com>
  • Loading branch information
timmyteo committed Jul 16, 2024
1 parent 80596aa commit 80af163
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Dosai/Dosai.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ private static List<AssemblyInformation> GetAssemblyInformation(string path)
}

var fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyFilePath);
#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
var buildPart = fileVersionInfo.FileBuildPart == null ? string.Empty : $".{fileVersionInfo.FileBuildPart}";
var privatePart = fileVersionInfo.FilePrivatePart == null ? string.Empty : $".{fileVersionInfo.FilePrivatePart}";
#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'

var assemblyInfo = new AssemblyInformation
{
Name = fileName,
Version = $"{fileVersionInfo.FileMajorPart}.{fileVersionInfo.FileMinorPart}.{fileVersionInfo.FileBuildPart}.{fileVersionInfo.FilePrivatePart}"
Version = $"{fileVersionInfo.FileMajorPart}.{fileVersionInfo.FileMinorPart}{buildPart}{privatePart}"
};

assemblyInformation.Add(assemblyInfo);
Expand Down

0 comments on commit 80af163

Please sign in to comment.