Skip to content

Commit

Permalink
Adding sample bot that renders several types of cards as attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Standefer committed Mar 8, 2017
1 parent 27fc422 commit 603e002
Show file tree
Hide file tree
Showing 85 changed files with 3,294 additions and 0 deletions.
507 changes: 507 additions & 0 deletions CSharp/demo-CardsAttachments/README.md

Large diffs are not rendered by default.

219 changes: 219 additions & 0 deletions CSharp/demo-CardsAttachments/Settings.StyleCop
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="EnumerationItemsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustContainValidXml">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotHaveDefaultSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustMatchElementParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="VoidReturnValueMustNotBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumentedPartialClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustMatchTypeParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustMatchAccessors">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustOmitSetAccessorWithRestrictedAccess">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotBeCopiedAndPasted">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SingleLineCommentsMustNotUseDocumentationStyleSlashes">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustNotBeEmpty">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustContainWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustMeetCharacterPercentage">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DestructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationHeadersMustNotContainBlankLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludedDocumentationXPathDoesNotExist">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludeNodeDoesNotContainValidFileAndPath">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="InheritDocMustBeUsedWithInheritingClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileMustHaveHeader">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustShowCopyright">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustHaveCopyrightText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustContainFileName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderFileNameDocumentationMustMatchFileName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustHaveValidCompanyText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
30 changes: 30 additions & 0 deletions CSharp/demo-CardsAttachments/SourceTool/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="codeItemsSection" type="SourceTool.CodeItemsSection, SourceTool" />
</configSections>

<codeItemsSection>
<codeItems>
<!-- we can use regex because we know function is implemented at the end of the class [regexs are not good to handle non-regular langs] -->
<add typeRegex="\s([\S]+)\s:\sRichCardScorable[^{]+{"
codeRegex="IList&lt;Attachment&gt;\sGetCardAttachments\(\)[^{]+{([\s\S]+)}[^}]+}[^}]+">
<replacements>
<add replacementRegex="return\s" replacementValue="message.Attachments = " />
</replacements>
</add>
</codeItems>
</codeItemsSection>

<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="configConsoleListener" type="System.Diagnostics.ConsoleTraceListener" />
</listeners>
</trace>
</system.diagnostics>

<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
17 changes: 17 additions & 0 deletions CSharp/demo-CardsAttachments/SourceTool/CodeItemCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace SourceTool
{
using System.Configuration;

public class CodeItemCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new CodeItemElement();
}

protected override object GetElementKey(ConfigurationElement element)
{
return ((CodeItemElement)element).TypeRegex;
}
}
}
73 changes: 73 additions & 0 deletions CSharp/demo-CardsAttachments/SourceTool/CodeItemElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
namespace SourceTool
{
using System.Configuration;
using System.Text.RegularExpressions;

public class CodeItemElement : ConfigurationElement
{
private Regex typeRegex;
private Regex codeRegex;

[ConfigurationProperty("typeRegex", IsRequired = true)]
public string TypeRegex
{
get
{
return (string)this["typeRegex"];
}

set
{
this["typeRegex"] = value;
}
}

[ConfigurationProperty("codeRegex", IsRequired = true)]
public string CodeRegex
{
get
{
return (string)this["codeRegex"];
}

set
{
this["codeRegex"] = value;
}
}

[ConfigurationProperty("replacements")]
public CodeReplacementCollection Replacements
{
get
{
return (CodeReplacementCollection)this["replacements"];
}

set
{
this["replacements"] = value;
}
}

public Regex GetTypeRegex()
{
if (this.typeRegex == null)
{
this.typeRegex = new Regex(this.TypeRegex, RegexOptions.Compiled);
}

return this.typeRegex;
}

public Regex GetCodeRegex()
{
if (this.codeRegex == null)
{
this.codeRegex = new Regex(this.CodeRegex, RegexOptions.Compiled);
}

return this.codeRegex;
}
}
}
21 changes: 21 additions & 0 deletions CSharp/demo-CardsAttachments/SourceTool/CodeItemsSection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace SourceTool
{
using System.Configuration;

public class CodeItemsSection : ConfigurationSection
{
[ConfigurationProperty("codeItems")]
public CodeItemCollection CodeItems
{
get
{
return (CodeItemCollection)this["codeItems"];
}

set
{
this["codeItems"] = value;
}
}
}
}
18 changes: 18 additions & 0 deletions CSharp/demo-CardsAttachments/SourceTool/CodeNodeComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SourceTool
{
using System.Collections.Generic;
using System.Xml.Linq;

internal class CodeNodeComparer : IEqualityComparer<XNode>
{
public bool Equals(XNode x, XNode y)
{
return (x as XElement).Attribute("type").ToString().Equals((y as XElement).Attribute("type").ToString());
}

public int GetHashCode(XNode obj)
{
return (obj as XElement).Attribute("type").ToString().GetHashCode();
}
}
}
Loading

0 comments on commit 603e002

Please sign in to comment.