diff --git a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs index 26474c8c87..beac7989c8 100644 --- a/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs +++ b/ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpAmbience.cs @@ -85,6 +85,7 @@ public void ConvertSymbol(ISymbol symbol, TokenWriter writer, CSharpFormattingOp break; case ClassType.RecordStruct: writer.WriteKeyword(Roles.RecordKeyword, "record"); + writer.Space(); writer.WriteKeyword(Roles.StructKeyword, "struct"); break; default: @@ -181,8 +182,7 @@ public void ConvertSymbol(ISymbol symbol, TokenWriter writer, CSharpFormattingOp if ((ConversionFlags & ConversionFlags.ShowBody) == ConversionFlags.ShowBody && !(node is TypeDeclaration)) { - IProperty property = symbol as IProperty; - if (property != null) + if (symbol is IProperty property) { writer.Space(); writer.WriteToken(Roles.LBrace, "{"); @@ -195,7 +195,10 @@ public void ConvertSymbol(ISymbol symbol, TokenWriter writer, CSharpFormattingOp } if (property.CanSet) { - writer.WriteKeyword(PropertyDeclaration.SetKeywordRole, "set"); + if ((ConversionFlags & ConversionFlags.SupportInitAccessors) != 0 && property.Setter.IsInitOnly) + writer.WriteKeyword(PropertyDeclaration.InitKeywordRole, "init"); + else + writer.WriteKeyword(PropertyDeclaration.SetKeywordRole, "set"); writer.WriteToken(Roles.Semicolon, ";"); writer.Space(); }