private void WriteCSharpImplementationDeferred(ICSharpWriter writer, ICSharpDeferredBody deferredBody, bool isOverride, string nameString, CSharpExports exportStatus, bool isConstructor, ref bool isFirstFeature, ref bool isMultiline) { CSharpArgument.BuildParameterList(writer, ParameterList, out string ParameterEntityList, out string ParameterNameList); CSharpAssertion.WriteContract(writer, deferredBody.RequireList, deferredBody.EnsureList, CSharpContractLocations.Other, true, ref isFirstFeature, ref isMultiline); string ExportStatusText = CSharpNames.ComposedExportStatus(false, true, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} void {nameString}({ParameterEntityList});"); isMultiline = false; }
private void WriteCSharpForcedReadWriteProperty(ICSharpWriter writer, bool isOverride, CSharpExports exportStatus, string propertyName, string resultType, ref bool isFirstFeature, ref bool isMultiline) { bool IsDeferred = false; bool IsPrecursor = false; isFirstFeature = false; if (GetterBody != null) { if (GetterBody is ICSharpDeferredBody) { IsDeferred = true; } if (GetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } } if (SetterBody != null) { if (SetterBody is ICSharpDeferredBody) { IsDeferred = true; } if (SetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } } if (GetterBody != null || SetterBody != null) { if (IsDeferred) { bool IsGetterMultiline = isMultiline; bool IsSetterMultiline = isMultiline; if (GetterBody != null) { ICSharpDeferredBody DeferredGetterBody = GetterBody as ICSharpDeferredBody; Debug.Assert(DeferredGetterBody != null); CSharpAssertion.WriteContract(writer, DeferredGetterBody.RequireList, DeferredGetterBody.EnsureList, CSharpContractLocations.Getter, false, ref isFirstFeature, ref IsGetterMultiline); IsSetterMultiline = false; } if (SetterBody != null) { ICSharpDeferredBody DeferredSetterBody = SetterBody as ICSharpDeferredBody; Debug.Assert(DeferredSetterBody != null); CSharpAssertion.WriteContract(writer, DeferredSetterBody.RequireList, DeferredSetterBody.EnsureList, CSharpContractLocations.Setter, false, ref isFirstFeature, ref IsSetterMultiline); } string ExportStatusText = CSharpNames.ComposedExportStatus(false, true, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName} {{ get; set; }}"); isMultiline = IsGetterMultiline || IsSetterMultiline; } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName}"); writer.WriteIndentedLine("{"); writer.IncreaseIndent(); if (IsPrecursor) { if (Source.PropertyKind != BaseNode.UtilityType.WriteOnly) { writer.WriteIndentedLine($"get {{ return base.{propertyName}; }}"); } else { writer.WriteIndentedLine($"get {{ throw new InvalidOperationException(); }}"); } if (Source.PropertyKind != BaseNode.UtilityType.ReadOnly) { writer.WriteIndentedLine($"set {{ base.{propertyName} = value; }}"); } else { writer.WriteIndentedLine($"set {{ throw new InvalidOperationException(); }}"); } } else { if (GetterBody != null) { ICSharpEffectiveBody EffectiveGetterBody = GetterBody as ICSharpEffectiveBody; Debug.Assert(EffectiveGetterBody != null); isMultiline = false; CSharpAssertion.WriteContract(writer, EffectiveGetterBody.RequireList, EffectiveGetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("get"); EffectiveGetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasResult, resultType, false, new List <string>()); } else { writer.WriteIndentedLine($"get {{ throw new InvalidOperationException(); }}"); } if (SetterBody != null) { ICSharpEffectiveBody EffectiveSetterBody = SetterBody as ICSharpEffectiveBody; Debug.Assert(EffectiveSetterBody != null); isMultiline = false; CSharpAssertion.WriteContract(writer, EffectiveSetterBody.RequireList, EffectiveSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("set"); EffectiveSetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasValue, string.Empty, false, new List <string>()); } else { writer.WriteIndentedLine($"set {{ throw new InvalidOperationException(); }}"); } } writer.DecreaseIndent(); writer.WriteIndentedLine("}"); isMultiline = true; } } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName}"); writer.WriteIndentedLine("{"); writer.IncreaseIndent(); if (Source.PropertyKind != BaseNode.UtilityType.WriteOnly) { writer.WriteIndentedLine($"get {{ return _{propertyName}; }}"); } else { writer.WriteIndentedLine($"get {{ throw new InvalidOperationException(); }}"); } if (Source.PropertyKind != BaseNode.UtilityType.ReadOnly) { writer.WriteIndentedLine($"set {{ _{propertyName} = value; }}"); } else { writer.WriteIndentedLine($"set {{ throw new InvalidOperationException(); }}"); } writer.DecreaseIndent(); writer.WriteIndentedLine("}"); isMultiline = true; } }
private void WriteCSharpWriteOnlyProperty(ICSharpWriter writer, bool isOverride, CSharpExports exportStatus, string propertyName, string resultType, ref bool isFirstFeature, ref bool isMultiline) { bool IsDeferred = false; bool IsPrecursor = false; isFirstFeature = false; if (SetterBody != null) { if (SetterBody is ICSharpDeferredBody) { IsDeferred = true; } if (SetterBody is ICSharpPrecursorBody) { IsPrecursor = true; } } if (SetterBody != null) { if (IsDeferred) { ICSharpDeferredBody DeferredSetterBody = SetterBody as ICSharpDeferredBody; Debug.Assert(DeferredSetterBody != null); CSharpAssertion.WriteContract(writer, DeferredSetterBody.RequireList, DeferredSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); string ExportStatusText = CSharpNames.ComposedExportStatus(false, true, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName} {{ protected get; set; }}"); isMultiline = false; } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName}"); if (IsPrecursor) { writer.WriteIndentedLine("{"); writer.IncreaseIndent(); writer.WriteIndentedLine($"set {{ base.{propertyName} = value; }}"); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } else { writer.WriteIndentedLine("{"); writer.IncreaseIndent(); writer.WriteIndentedLine($"protected get {{ return _{propertyName}; }}"); ICSharpEffectiveBody EffectiveSetterBody = SetterBody as ICSharpEffectiveBody; Debug.Assert(EffectiveSetterBody != null); isMultiline = false; CSharpAssertion.WriteContract(writer, EffectiveSetterBody.RequireList, EffectiveSetterBody.EnsureList, CSharpContractLocations.Other, false, ref isFirstFeature, ref isMultiline); writer.WriteIndentedLine("set"); EffectiveSetterBody.WriteCSharp(writer, CSharpBodyFlags.MandatoryCurlyBrackets | CSharpBodyFlags.HasValue, string.Empty, false, new List <string>()); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } isMultiline = true; } } else { if (isMultiline) { writer.WriteEmptyLine(); } string ExportStatusText = CSharpNames.ComposedExportStatus(IsOverride, false, false, exportStatus); writer.WriteIndentedLine($"{ExportStatusText} {resultType} {propertyName} {{ protected get; set; }}"); isMultiline = false; } }