Skip to content

Commit

Permalink
Allow for null values, including empty categories
Browse files Browse the repository at this point in the history
  • Loading branch information
citizenmatt committed Oct 24, 2014
1 parent e00ed09 commit 37c8221
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions src/resharper-template-compiler/ReadmeFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,26 @@ public void FormatTemplates(TemplateStore templates)
writer.WriteLine("# Templates");
writer.WriteLine();

if (templatesByCategory.Count == 0)
FormatTemplates(templates.Templates);

foreach (var category in templatesByCategory.Keys.OrderBy(s => s))
{
// TODO: Perhaps split this down into template type - Live, Surround or File
writer.WriteLine("## {0}", category);
writer.WriteLine();
writer.WriteLine("Shortcut | Description");
writer.WriteLine("---------|------------");
foreach (var template in templatesByCategory[category].OrderBy(t => t.Shortcut))
writer.WriteLine("[{0}]({0}.md) | {1}", template.Shortcut, template.Description);

writer.WriteLine();
FormatTemplates(templatesByCategory[category]);
}
}

private void FormatTemplates(IEnumerable<Template> templates)
{
writer.WriteLine();
writer.WriteLine("Shortcut | Description");
writer.WriteLine("---------|------------");
foreach (var template in templates.OrderBy(t => t.Shortcut))
writer.WriteLine("[{0}]({0}.md) | {1}", template.Shortcut, template.Description);

writer.WriteLine();
}
}
}
2 changes: 1 addition & 1 deletion src/resharper-template-compiler/SettingsDeserialisation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private Template DeserialiseTemplate(Guid guid)
template.Description = description;
template.Text = GetValue<string>(templatePath, "Text");
template.Reformat = TryGetValue(templatePath, "Reformat", true);
template.ShortenQualifiedReferences = TryGetValue<bool>(templatePath, "ShortenQualifiedReferences", true);
template.ShortenQualifiedReferences = TryGetValue(templatePath, "ShortenQualifiedReferences", true);
template.Scopes = DeserialiseScopes(templatePath);
template.Categories = DeserialiseCategories(templatePath);
template.Fields = DeserialiseFields(templatePath);
Expand Down
2 changes: 1 addition & 1 deletion src/resharper-template-compiler/SettingsSerialisation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void SerialiseToXaml(TextWriter textWriter, SettingsSerialisation
xmlWriter.WriteAttributeString("xmlns", "x", null, "http://schemas.microsoft.com/winfx/2006/xaml");
xmlWriter.WriteAttributeString("xmlns", "s", null, "clr-namespace:System;assembly=mscorlib");
xmlWriter.WriteAttributeString("xmlns", "ss", null, "urn:shemas-jetbrains-com:settings-storage-xaml");
foreach (var entry in serialisation.dictionary.OrderBy(p => p.Key))
foreach (var entry in serialisation.dictionary.OrderBy(p => p.Key).Where(p => p.Value != null))
{
xmlWriter.WriteStartElement("s", entry.Value.GetType().Name,
"clr-namespace:System;assembly=mscorlib");
Expand Down

0 comments on commit 37c8221

Please sign in to comment.