|
2 | 2 | using Microsoft.CodeAnalysis; |
3 | 3 | using Microsoft.Xml.XMLGen; |
4 | 4 | using System; |
| 5 | +using System.CodeDom; |
5 | 6 | using System.Collections.Generic; |
6 | 7 | using System.IO; |
7 | 8 | using System.Linq; |
@@ -34,6 +35,7 @@ private IEnumerable<string> ConvertXml(string name, string xsd, Generator genera |
34 | 35 | EntityFramework = generatorPrototype.EntityFramework, |
35 | 36 | GenerateInterfaces = generatorPrototype.GenerateInterfaces, |
36 | 37 | MemberVisitor = generatorPrototype.MemberVisitor, |
| 38 | + CodeTypeReferenceOptions = generatorPrototype.CodeTypeReferenceOptions |
37 | 39 | }; |
38 | 40 |
|
39 | 41 | var set = new XmlSchemaSet(); |
@@ -338,7 +340,45 @@ public void DontGenerateElementForEmptyCollectionInChoice() |
338 | 340 | Assert.DoesNotContain("tags", xml, StringComparison.OrdinalIgnoreCase); |
339 | 341 | } |
340 | 342 |
|
341 | | - [Fact] |
| 343 | + |
| 344 | + [Theory] |
| 345 | + [InlineData(CodeTypeReferenceOptions.GlobalReference, "[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]")] |
| 346 | + [InlineData((CodeTypeReferenceOptions)0, "[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]")] |
| 347 | + public void EditorBrowsableAttributeRespectsCodeTypeReferenceOptions(CodeTypeReferenceOptions codeTypeReferenceOptions, string expectedLine) |
| 348 | + { |
| 349 | + const string xsd = @"<?xml version=""1.0"" encoding=""UTF-8""?> |
| 350 | +<xs:schema elementFormDefault=""qualified"" xmlns:xs=""http://www.w3.org/2001/XMLSchema""> |
| 351 | + <xs:complexType name=""document""> |
| 352 | + <xs:attribute name=""some-value""> |
| 353 | + <xs:simpleType> |
| 354 | + <xs:restriction base=""xs:string""> |
| 355 | + <xs:enumeration value=""one""/> |
| 356 | + <xs:enumeration value=""two""/> |
| 357 | + </xs:restriction> |
| 358 | + </xs:simpleType> |
| 359 | + </xs:attribute> |
| 360 | + <xs:attribute name=""system"" type=""xs:string""/> |
| 361 | + </xs:complexType> |
| 362 | +</xs:schema>"; |
| 363 | + |
| 364 | + var generatedType = ConvertXml(nameof(EditorBrowsableAttributeRespectsCodeTypeReferenceOptions), xsd, new Generator |
| 365 | + { |
| 366 | + CodeTypeReferenceOptions = codeTypeReferenceOptions, |
| 367 | + GenerateNullables = true, |
| 368 | + GenerateInterfaces = false, |
| 369 | + NamespaceProvider = new NamespaceProvider |
| 370 | + { |
| 371 | + GenerateNamespace = key => "Test" |
| 372 | + } |
| 373 | + }); |
| 374 | + |
| 375 | + Assert.Contains( |
| 376 | + expectedLine, |
| 377 | + generatedType.First()); |
| 378 | + } |
| 379 | + |
| 380 | + |
| 381 | + [Fact] |
342 | 382 | public void ComplexTypeWithAttributeGroupExtension() |
343 | 383 | { |
344 | 384 | const string xsd = @"<?xml version=""1.0"" encoding=""UTF-8""?> |
|
0 commit comments