Browse Source

Clean up some properties in TranslationUnit.cs with null coalescing operators.

pull/1543/head
Joao Matos 5 years ago committed by João Matos
parent
commit
db08034d4b
  1. 11
      src/AST/TranslationUnit.cs

11
src/AST/TranslationUnit.cs

@ -38,18 +38,14 @@ namespace CppSharp.AST
private string fileNameWithoutExtension; private string fileNameWithoutExtension;
/// Contains the name of the file. /// Contains the name of the file.
public string FileName public string FileName => !IsValid ? FilePath : fileName ??= Path.GetFileName(FilePath);
{
get { return !IsValid ? FilePath : fileName ?? (fileName = Path.GetFileName(FilePath)); }
}
/// Contains the name of the module. /// Contains the name of the module.
public string FileNameWithoutExtension public string FileNameWithoutExtension
{ {
get get
{ {
return fileNameWithoutExtension ?? return fileNameWithoutExtension ??= Path.GetFileNameWithoutExtension(FileName);
(fileNameWithoutExtension = Path.GetFileNameWithoutExtension(FileName));
} }
} }
@ -83,8 +79,7 @@ namespace CppSharp.AST
get get
{ {
if (!IsValid) return string.Empty; if (!IsValid) return string.Empty;
return fileRelativePath ?? return fileRelativePath ??= Path.Combine(FileRelativeDirectory, FileName);
(fileRelativePath = Path.Combine(FileRelativeDirectory, FileName));
} }
} }

Loading…
Cancel
Save