示例#1
0
    public void WriteProperty(PropertyDefinition definition, ISourceCodeOutput output, DecompilerOptions options)
    {
      output.WriteDefinition(".property ", definition);
      output.Write(definition.HasThis ? "instance " : "class ");
      if (definition.PropertyType.IsValueType && !definition.PropertyType.IsPrimitive)
        output.Write("valuetype ");

      output.Write(definition.PropertyType.ToShortTypeName() + " ");
      output.Write(definition.Name);

      OpenBlock(output);

      if (definition.HasCustomAttributes)
        WriteCustomAttributes(definition.CustomAttributes, output);

      if (definition.HasGetter())
      {
        var getter = definition.GetMethod;
        var returnType = getter.MethodReturnType.ReturnType;
        output.Write(".get ");
        if (getter.HasThis) output.Write("instance ");
        if (returnType.IsValueType && !returnType.IsPrimitive) output.Write("valuetype ");
        // TODO: To be unwrapped
        output.WriteLine(getter.ToString());
      }

      if (definition.HasSetter())
      {
        var setter = definition.SetMethod;
        output.Write(".set ");
        if (setter.HasThis) output.Write("instance ");
        output.WriteLine(setter.ToString());
      }

      CloseBlock(output);
    }