示例#1
0
        protected static void AssertXmlDeclaration(string classResource, string xmlResource, string documentationPath = null, JavaDocletType?javaDocletType = null)
        {
            var classPathBuilder = new ClassPath()
            {
                ApiSource          = "class-parse",
                DocumentationPaths = new string[] {
                    documentationPath,
                },
            };

            if (javaDocletType.HasValue)
            {
                classPathBuilder.DocletType = javaDocletType.Value;
            }
            classPathBuilder.Add(LoadClassFile(classResource));

            var actual = new StringWriter();

            classPathBuilder.ApiSource = "class-parse";
            if (javaDocletType.HasValue)
            {
                classPathBuilder.DocletType = javaDocletType.Value;
            }
            classPathBuilder.SaveXmlDescription(actual);

            var expected = LoadString(xmlResource);

            Assert.AreEqual(expected, actual.ToString());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpQualifiedName"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly node from which the C# node is created.</param>
        /// <param name="feature">The feature at the end of the path. Can be null.</param>
        /// <param name="discrete">The discrete at the end of the path. Can be null.</param>
        /// <param name="inheritBySideAttribute">Inherit the side-by-side attribute.</param>
        protected CSharpQualifiedName(ICSharpContext context, IQualifiedName source, ICSharpFeature feature, ICSharpDiscrete discrete, bool inheritBySideAttribute)
            : base(source)
        {
            Debug.Assert((feature != null && discrete == null) || (feature == null && discrete != null));

            Feature  = feature;
            Discrete = discrete;
            InheritBySideAttribute  = inheritBySideAttribute;
            IsAttributeWithContract = feature is ICSharpAttributeFeature AsAttributeFeature && AsAttributeFeature.Source.EnsureList.Count > 0;

            foreach (IExpressionType Item in source.ValidResultTypePath.Item)
            {
                ICSharpClass ItemClass;

                if (Item.ValueType is IClassType AsClassType)
                {
                    ItemClass = context.GetClass(AsClassType.BaseClass);
                }
                else
                {
                    ItemClass = null;
                }

                ClassPath.Add(ItemClass);
            }
        }
示例#3
0
 static void DumpFileToXml(ClassPath jar, string file)
 {
     using (var s = File.OpenRead(file)) {
         if (ClassFile.IsClassFile(s))
         {
             s.Position = 0;
             var c = new ClassFile(s);
             jar.Add(c);
             return;
         }
     }
     if (ClassPath.IsJarFile(file))
     {
         jar.Load(file);
         return;
     }
     Console.Error.WriteLine("class-parse: Unable to read file '{0}': Unknown file format.");
     Environment.ExitCode = 1;
 }
示例#4
0
        protected static void AssertXmlDeclaration(string[] classResources, string xmlResource, string documentationPath = null)
        {
            var classPathBuilder = new ClassPath()
            {
                ApiSource          = "class-parse",
                DocumentationPaths = new string[] {
                    documentationPath,
                },
                AutoRename = true
            };

            foreach (var classFile in classResources.Select(s => LoadClassFile(s)))
            {
                classPathBuilder.Add(classFile);
            }

            var actual = new StringWriter();

            classPathBuilder.SaveXmlDescription(actual);

            var expected = LoadString(xmlResource);

            Assert.AreEqual(expected, actual.ToString());
        }