예제 #1
0
 public void Append(CSTWriter w)
 {
     foreach (var customAttribute in CustomAttributes)
     {
         customAttribute.Append(w);
         w.EndLine();
     }
     w.Append("assembly ");
     Name.Append(w);
     w.Append(" {");
     w.EndLine();
     w.Indented(w2 => {
         foreach (var sn in References)
         {
             w2.Append(".reference ");
             sn.Append(w2);
             w2.EndLine();
         }
         if (EntryPoint != null)
         {
             w2.Append(".entry ");
             EntryPoint.Append(w2);
             w2.EndLine();
         }
         foreach (var namedTypeDef in Types)
         {
             namedTypeDef.AppendDefinition(w2);
             w2.EndLine();
         }
     });
     w.Append('}');
 }
예제 #2
0
        public void Append(CSTWriter w)
        {
            switch (w.Style)
            {
            case WriterStyle.ReflectionFullName:
            case WriterStyle.Uniform:
                w.Append('[');
                Assembly.Append(w);
                w.Append(']');
                Type.Append(w);
                break;

            case WriterStyle.ReflectionName:
                // no assembly
                Type.Append(w);
                break;

            case WriterStyle.Debug:
            {
                // elide *mscorlib, elide assembly version etc
                if (Assembly.Name == null)
                {
                    w.Append('[');
                    w.Append(AssemblyName.unavailableSimpleName);
                    w.Append(']');
                }
                else if (!Assembly.Name.Contains(Global.MSCorLibSimpleName))
                {
                    w.Append('[');
                    w.AppendName(Assembly.Name);
                    w.Append(']');
                }
                // shorten the built-in type names
                var nm = default(string);
                if (w.Global.TypeNameToAbbreviation.TryGetValue(Type, out nm) && nm != null)
                {
                    w.Append(nm);
                }
                else
                {
                    Type.Append(w);
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }