diff --git a/src/AST/Class.cs b/src/AST/Class.cs index 1cd6215b..5e207c00 100644 --- a/src/AST/Class.cs +++ b/src/AST/Class.cs @@ -145,15 +145,9 @@ namespace CppSharp.AST specializations = new List(); } - public bool HasBase - { - get { return Bases.Count > 0; } - } + public bool HasBase => Bases.Count > 0; - public bool HasBaseClass - { - get { return BaseClass != null; } - } + public bool HasBaseClass => BaseClass != null; public Class BaseClass { diff --git a/src/AST/Declaration.cs b/src/AST/Declaration.cs index 1b97e997..71dfc8fc 100644 --- a/src/AST/Declaration.cs +++ b/src/AST/Declaration.cs @@ -79,7 +79,7 @@ namespace CppSharp.AST /// /// Whether the declaration was explicitly set to be generated via - /// the GenerationKind propery as opposed to the default generated state. + /// the GenerationKind property as opposed to the default generated state. /// public virtual bool IsExplicitlyGenerated => generationKind.HasValue && generationKind.Value == GenerationKind.Generate; diff --git a/src/AST/Enumeration.cs b/src/AST/Enumeration.cs index 40406437..94a651f0 100644 --- a/src/AST/Enumeration.cs +++ b/src/AST/Enumeration.cs @@ -29,10 +29,9 @@ namespace CppSharp.AST { get { - if (Expression == null) - { + if (string.IsNullOrEmpty(Expression)) return false; - } + return Expression.Contains("0x") || Expression.Contains("0X"); } } diff --git a/src/AST/Event.cs b/src/AST/Event.cs index 738f7679..03e32ea3 100644 --- a/src/AST/Event.cs +++ b/src/AST/Event.cs @@ -9,7 +9,7 @@ namespace CppSharp.AST return visitor.VisitEvent(this); } - public Type Type { get { return QualifiedType.Type; } } + public Type Type => QualifiedType.Type; public QualifiedType QualifiedType { get; set; } public List Parameters { get; } = new List(); diff --git a/src/Generator/Generators/C/CppGenerator.cs b/src/Generator/Generators/C/CppGenerator.cs index 6a167c50..73a2aa8d 100644 --- a/src/Generator/Generators/C/CppGenerator.cs +++ b/src/Generator/Generators/C/CppGenerator.cs @@ -37,7 +37,7 @@ namespace CppSharp.Generators.Cpp return true; } - public static bool ShouldGenerateClassNativeField(Class @class) + public static bool ShouldGenerateClassNativeInstanceField(Class @class) { if (@class.IsStatic) return false; diff --git a/src/Generator/Generators/C/CppHeaders.cs b/src/Generator/Generators/C/CppHeaders.cs index 47fbf2e2..e58e4e88 100644 --- a/src/Generator/Generators/C/CppHeaders.cs +++ b/src/Generator/Generators/C/CppHeaders.cs @@ -326,7 +326,7 @@ namespace CppSharp.Generators.Cpp VisitDeclContext(@class); Unindent(); - if (CppGenerator.ShouldGenerateClassNativeField(@class)) + if (CppGenerator.ShouldGenerateClassNativeInstanceField(@class)) GenerateClassNativeField(@class); GenerateClassConstructors(@class); @@ -339,7 +339,7 @@ namespace CppSharp.Generators.Cpp GenerateClassVariables(@class); - if (CppGenerator.ShouldGenerateClassNativeField(@class)) + if (CppGenerator.ShouldGenerateClassNativeInstanceField(@class)) { PushBlock(BlockKind.AccessSpecifier); WriteLine("protected:"); diff --git a/src/Generator/Generators/CLI/CLITypeReferences.cs b/src/Generator/Generators/CLI/CLITypeReferences.cs index 298d0398..701f9ac8 100644 --- a/src/Generator/Generators/CLI/CLITypeReferences.cs +++ b/src/Generator/Generators/CLI/CLITypeReferences.cs @@ -31,10 +31,7 @@ namespace CppSharp.Generators.CLI private TranslationUnit TranslationUnit; private Dictionary typeReferences; - public IEnumerable TypeReferences - { - get { return typeReferences.Values; } - } + public IEnumerable TypeReferences => typeReferences.Values; public HashSet GeneratedDeclarations; diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs index 2a7ce847..6ab94bbc 100644 --- a/src/Generator/Passes/CheckIgnoredDecls.cs +++ b/src/Generator/Passes/CheckIgnoredDecls.cs @@ -568,8 +568,7 @@ namespace CppSharp.Passes if (parameter.Type.Desugar().IsPrimitiveType(PrimitiveType.Null)) return true; - TypeMap typeMap; - if (TypeMaps.FindTypeMap(parameter.Type, out typeMap)) + if (TypeMaps.FindTypeMap(parameter.Type, out var typeMap)) return typeMap.IsIgnored; } diff --git a/src/Generator/Utils/BlockGenerator.cs b/src/Generator/Utils/BlockGenerator.cs index c1a1f1d1..f1ebcf1d 100644 --- a/src/Generator/Utils/BlockGenerator.cs +++ b/src/Generator/Utils/BlockGenerator.cs @@ -172,10 +172,7 @@ namespace CppSharp { get { - if (Blocks.Any(block => !block.IsEmpty)) - return false; - - return string.IsNullOrEmpty(Text.ToString()); + return Blocks.All(block => block.IsEmpty) && string.IsNullOrEmpty(Text.ToString()); } } @@ -275,10 +272,18 @@ namespace CppSharp public void PushBlock(BlockKind kind = BlockKind.Unknown, object obj = null) { - var block = new Block { Kind = kind, Object = obj }; - block.Text.CurrentIndentation = CurrentIndentation; - block.Text.IsStartOfLine = ActiveBlock.Text.IsStartOfLine; - block.Text.NeedsNewLine = ActiveBlock.Text.NeedsNewLine; + var block = new Block + { + Kind = kind, + Object = obj, + Text = + { + CurrentIndentation = CurrentIndentation, + IsStartOfLine = ActiveBlock.Text.IsStartOfLine, + NeedsNewLine = ActiveBlock.Text.NeedsNewLine + } + }; + PushBlock(block); }