Skip to content

Commit 54c7b1c

Browse files
committed
Hook up to Program.cs - runs through, no annotations applied. Something is not workin as expected.
1 parent 3482609 commit 54c7b1c

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

src/Typewriter/CsdlExtensionMethods.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace Typewriter
44
{
55
using ApiDoctor.Validation;
66
using ApiDoctor.Validation.Error;
7+
using ApiDoctor.Validation.OData;
8+
using ApiDoctor.Validation.Utility;
79
using System;
810
using System.Collections.Generic;
911
using System.Linq;
@@ -102,13 +104,13 @@ private static string NormalizeFunctionParameters(string funcParams, IssueLogger
102104
return string.Join(",", allParams.OrderBy(p => p));
103105
}
104106

105-
public static string HttpMethodVerb(this MethodDefinition method)
106-
{
107-
HttpParser parser = new HttpParser();
108-
var request = parser.ParseHttpRequest(method.Request);
109-
return request.Method;
107+
//public static string HttpMethodVerb(this MethodDefinition method)
108+
//{
109+
// HttpParser parser = new HttpParser();
110+
// var request = parser.ParseHttpRequest(method.Request);
111+
// return request.Method;
110112

111-
}
113+
//}
112114

113115
internal static void AppendWithCondition(this System.Text.StringBuilder sb, bool condition, string text, string prefixIfExistingContent = null)
114116
{
@@ -153,11 +155,6 @@ internal static EntityFramework MergeWith(this EntityFramework framework1, Entit
153155

154156
return edmx;
155157

156-
157158
}
158-
159-
160-
161-
162159
}
163160
}

src/Typewriter/DocAnnotationWriter.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using ApiDoctor.Validation;
33
using ApiDoctor.Validation.Error;
44
using ApiDoctor.Validation.OData;
5+
using ApiDoctor.Validation.OData.Transformation;
56
using NLog;
67
using System;
78
using System.Collections.Generic;
@@ -15,22 +16,25 @@ namespace Typewriter
1516
internal class DocAnnotationWriter : ApiDoctor.Publishing.CSDL.CsdlWriter// or this a helper, will name this later
1617
{
1718
private static Logger Logger => LogManager.GetLogger("DocAnnotationWriter");
18-
private string csdl;
19+
//private string csdl;
1920

2021
internal IssueLogger IssueLogger { get; set; }
2122
internal DocSet DocSet { get; set; }
23+
internal string Csdl { get; set; }
2224

2325
private readonly CsdlWriterOptions options;
2426

2527
internal DocAnnotationWriter(DocSet docSet, CsdlWriterOptions options, string csdl) : base(docSet, options)
2628
{
27-
this.csdl = csdl;
29+
this.Csdl = csdl;
2830
this.DocSet = docSet;
2931
this.options = options; // Can change the base access modifier so we could use it.
3032
}
3133

32-
private async Task<string> PublishToStringAsync(IssueLogger issues)
34+
public async Task<string> PublishToStringAsync(IssueLogger issues)
3335
{
36+
string outputFilenameSuffix = "";
37+
3438
// Step 1: Generate an EntityFramework OM from the documentation and/or template file
3539
EntityFramework framework = CreateEntityFrameworkFromDocs(issues);
3640
if (null == framework)
@@ -72,15 +76,7 @@ private async Task<string> PublishToStringAsync(IssueLogger issues)
7276
}
7377

7478
// Step 2: Generate XML representation of EDMX
75-
string xmlData = null;
76-
if (options.Formats.HasFlag(MetadataFormat.EdmxOutput))
77-
{
78-
xmlData = ODataParser.Serialize<EntityFramework>(framework, options.AttributesOnNewLines);
79-
}
80-
else if (options.Formats.HasFlag(MetadataFormat.SchemaOutput))
81-
{
82-
xmlData = ODataParser.Serialize<Schema>(framework.DataServices.Schemas.First(), options.AttributesOnNewLines);
83-
}
79+
string xmlData = ODataParser.Serialize<EntityFramework>(framework, options.AttributesOnNewLines);
8480

8581
return xmlData;
8682
}
@@ -90,7 +86,7 @@ internal static class AnnotationHelper
9086
{
9187
private static Logger Logger => LogManager.GetLogger("AnnotationHelper");
9288

93-
internal static string ApplyAnnotationsToCsdl(string csdl, Options options)
89+
internal async static Task<string> ApplyAnnotationsToCsdl(string csdl, Options options)
9490
{
9591
// Get DocSet
9692
DocSet docs = GetDocSet(options, new IssueLogger());
@@ -100,7 +96,7 @@ internal static string ApplyAnnotationsToCsdl(string csdl, Options options)
10096
// Create DocAnnotationWriter
10197
DocAnnotationWriter docWriter = new DocAnnotationWriter(docs, csdlWriterOptions, csdl);
10298

103-
throw new NotImplementedException();
99+
return await docWriter.PublishToStringAsync(new IssueLogger());
104100
}
105101

106102
private static DocSet GetDocSet(Options options, IssueLogger issues)
@@ -120,6 +116,7 @@ private static DocSet GetDocSet(Options options, IssueLogger issues)
120116

121117
Logger.Info("Scanning documentation files");
122118
var stopwatch = new Stopwatch();
119+
stopwatch.Start();
123120
docSet.ScanDocumentation(string.Empty, issues);
124121
stopwatch.Stop();
125122
Logger.Info($"Took {stopwatch.Elapsed} to parse {docSet.Files.Length} source files.");

src/Typewriter/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private static void GenerateSDK(Options options)
3939
string processedCsdlContents = MetadataPreprocessor.CleanMetadata(csdlContents);
4040

4141
// Inject documentation annotations into the CSDL using ApiDoctor.
42-
string csdlWithDocAnnotations = AnnotationHelper.ApplyAnnotationsToCsdl(processedCsdlContents, options);
42+
string csdlWithDocAnnotations = AnnotationHelper.ApplyAnnotationsToCsdl(processedCsdlContents, options).Result;
4343

4444
var files = MetadataToClientSource(csdlWithDocAnnotations, options.Language);
4545
FileWriter.WriteAsync(files, options.Output);
@@ -90,6 +90,9 @@ private static void HandleError(IEnumerable<Error> errors)
9090

9191
static private IEnumerable<TextFile> MetadataToClientSource(string edmxString, string targetLanguage)
9292
{
93+
if (String.IsNullOrEmpty(edmxString))
94+
throw new ArgumentNullException("edmxString", "The EDMX file string contains no content.");
95+
9396
var reader = new OdcmReader();
9497
var writer = new TemplateWriter(targetLanguage);
9598
writer.SetConfigurationProvider(new ConfigurationProvider());

0 commit comments

Comments
 (0)