Skip to content

Commit

Permalink
Code cleanup + nuspec + improved multiple files export
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-b-novikov committed Oct 22, 2015
1 parent c369416 commit 0356c38
Show file tree
Hide file tree
Showing 68 changed files with 1,580 additions and 1,198 deletions.
20 changes: 8 additions & 12 deletions Reinforced.Typings/AccessModifier.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reinforced.Typings
namespace Reinforced.Typings
{
/// <summary>
/// Represents member's access modifier
/// Represents member's access modifier
/// </summary>
public enum AccessModifier
{
/// <summary>
/// private
/// private
/// </summary>
Private,

/// <summary>
/// protected
/// protected
/// </summary>
Protected,

/// <summary>
/// public
/// public
/// </summary>
Public
}
}
}
16 changes: 8 additions & 8 deletions Reinforced.Typings/Attributes/IAutoexportSwitchAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
namespace Reinforced.Typings.Attributes
{
/// <summary>
/// Interface containing base properties for some attributes
/// Interface containing base properties for some attributes
/// </summary>
public interface IAutoexportSwitchAttribute
{
/// <summary>
/// When true, code for all methods will be automatically generated
/// When true, code for all methods will be automatically generated
/// </summary>
bool AutoExportMethods { get; set; }

/// <summary>
/// When true, code for all properties will be automatically generated
/// When true, code for all properties will be automatically generated
/// </summary>
bool AutoExportProperties { get; set; }

/// <summary>
/// When true, code for all fields will be automatically generated
/// When true, code for all fields will be automatically generated
/// </summary>
bool AutoExportFields { get; }

/// <summary>
/// Reference to code geenrator which will be applied to every method
/// Reference to code geenrator which will be applied to every method
/// </summary>
Type DefaultMethodCodeGenerator { get; }

/// <summary>
/// When true, code for all constructors will be automatically generated
/// When true, code for all constructors will be automatically generated
/// </summary>
bool AutoExportConstructors { get; }
}
}
}
18 changes: 6 additions & 12 deletions Reinforced.Typings/Attributes/INameOverrideAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reinforced.Typings.Attributes
namespace Reinforced.Typings.Attributes
{
/// <summary>
/// Configuration interface for members supporting names overriding
/// Configuration interface for members supporting names overriding
/// </summary>
public interface INameOverrideAttribute
{
/// <summary>
/// Name override
/// Name override
/// </summary>
string Name { get; set; }
}

/// <summary>
/// Configuration interface for members supporting camelCasing from attribute
/// Configuration interface for members supporting camelCasing from attribute
/// </summary>
public interface ICamelCaseableAttribute
{
/// <summary>
/// camelCase flag
/// camelCase flag
/// </summary>
bool ShouldBeCamelCased { get; set; }
}
}
}
36 changes: 16 additions & 20 deletions Reinforced.Typings/Attributes/TsAddTypeReference.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reinforced.Typings.Attributes
{

/// <summary>
/// This attribute is used to add reference directive to file containing single TS class typing.
/// It is only used while splitting generated type sto different files
/// This attribute is used to add reference directive to file containing single TS class typing.
/// It is only used while splitting generated type sto different files
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum, AllowMultiple = true)]
public class TsAddTypeReferenceAttribute : Attribute
{
/// <summary>
/// Type that should be referenced
/// </summary>
public Type Type { get; set; }

/// <summary>
/// Raw reference path that will be added to target file
/// </summary>
public string RawPath { get; set; }

/// <summary>
/// Constructs new instance of TsAddTypeReferenceAttribute using referenced type
/// Constructs new instance of TsAddTypeReferenceAttribute using referenced type
/// </summary>
/// <param name="type">Type reference</param>
public TsAddTypeReferenceAttribute(Type type)
Expand All @@ -33,12 +19,22 @@ public TsAddTypeReferenceAttribute(Type type)
}

/// <summary>
/// Constructs new instance of TsAddTypeReferenceAttribute using referenced type
/// Constructs new instance of TsAddTypeReferenceAttribute using referenced type
/// </summary>
/// <param name="rawPath">Raw reference</param>
public TsAddTypeReferenceAttribute(string rawPath)
{
RawPath = rawPath;
}

/// <summary>
/// Type that should be referenced
/// </summary>
public Type Type { get; set; }

/// <summary>
/// Raw reference path that will be added to target file
/// </summary>
public string RawPath { get; set; }
}
}
}
8 changes: 4 additions & 4 deletions Reinforced.Typings/Attributes/TsAttributeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Reinforced.Typings.Attributes
{
/// <summary>
/// Base for all attributes
/// Base for all attributes
/// </summary>
public abstract class TsAttributeBase : Attribute
{
/// <summary>
/// Dummy function body generator
/// If empty then it's being generated empty/return null body.
/// Dummy function body generator
/// If empty then it's being generated empty/return null body.
/// </summary>
public virtual Type CodeGeneratorType { get; set; }
}
}
}
26 changes: 11 additions & 15 deletions Reinforced.Typings/Attributes/TsBaseParamAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reinforced.Typings.Attributes
{
/// <summary>
/// Denotes parameter name and constant value for constructor's :base call
/// We need this attribute because it is programmatically impossible to determine :base call parameters
/// via reflection. So in this case we need some help from user's side
/// Denotes parameter name and constant value for constructor's :base call
/// We need this attribute because it is programmatically impossible to determine :base call parameters
/// via reflection. So in this case we need some help from user's side
/// </summary>
[AttributeUsage(AttributeTargets.Constructor)]
public class TsBaseParamAttribute : Attribute
{
/// <summary>
/// Parameters for super() call
/// Here should be stored TypeScript expressions
/// </summary>
public string[] Values { get; set; }

/// <summary>
/// Creates instance of TsBaseParamAttribute
/// Creates instance of TsBaseParamAttribute
/// </summary>
/// <param name="values">Set of TypeScript expressions to be supplied for super() call</param>
public TsBaseParamAttribute(params string[] values)
{
Values = values;
}

/// <summary>
/// Parameters for super() call
/// Here should be stored TypeScript expressions
/// </summary>
public string[] Values { get; set; }
}
}
}
36 changes: 18 additions & 18 deletions Reinforced.Typings/Attributes/TsClassAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
namespace Reinforced.Typings.Attributes
{
/// <summary>
/// This attribute will export member as typescript class definition
/// This attribute will export member as typescript class definition
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class TsClassAttribute : TsDeclarationAttributeBase, IAutoexportSwitchAttribute
{
/// <summary>
/// Export all methods automatically or not.
/// Constructs new instance of TsClassAttribute
/// </summary>
public TsClassAttribute()
{
AutoExportProperties = true;
AutoExportMethods = true;
IncludeNamespace = true;
AutoExportConstructors = false;
}

/// <summary>
/// Export all methods automatically or not.
/// </summary>
public virtual bool AutoExportMethods { get; set; }

/// <summary>
/// Export all properties automatically or not.
/// Export all properties automatically or not.
/// </summary>
public virtual bool AutoExportProperties { get; set; }

/// <summary>
/// Export all fields automatically or not.
/// Export all fields automatically or not.
/// </summary>
public virtual bool AutoExportFields { get; set; }

/// <summary>
/// Reference to code geenrator which will be applied to every method
/// Reference to code geenrator which will be applied to every method
/// </summary>
public virtual Type DefaultMethodCodeGenerator { get; set; }

/// <summary>
/// When true, code for all constructors will be automatically generated
/// When true, code for all constructors will be automatically generated
/// </summary>
public bool AutoExportConstructors { get; set; }

/// <summary>
/// Constructs new instance of TsClassAttribute
/// </summary>
public TsClassAttribute()
{
AutoExportProperties = true;
AutoExportMethods = true;
IncludeNamespace = true;
AutoExportConstructors = false;
}
}
}
}
24 changes: 12 additions & 12 deletions Reinforced.Typings/Attributes/TsDeclarationAttributeBase.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
namespace Reinforced.Typings.Attributes
{
/// <summary>
/// Base attribute for so-called compilation unit (class, enum, interface etc)
/// Base attribute for so-called compilation unit (class, enum, interface etc)
/// </summary>
public abstract class TsDeclarationAttributeBase : TsAttributeBase, INameOverrideAttribute
{
/// <summary>
/// Place to corresponding namespace
/// Constructs new instance of TsDeclarationAttributeBase
/// </summary>
public virtual bool IncludeNamespace { get; set; }
protected TsDeclarationAttributeBase()
{
IncludeNamespace = true;
}

/// <summary>
/// Overrides name
/// Place to corresponding namespace
/// </summary>
public virtual string Name { get; set; }
public virtual bool IncludeNamespace { get; set; }

/// <summary>
/// Overrides namespace
/// Overrides namespace
/// </summary>
public virtual string Namespace { get; set; }

/// <summary>
/// Constructs new instance of TsDeclarationAttributeBase
/// Overrides name
/// </summary>
protected TsDeclarationAttributeBase()
{
IncludeNamespace = true;
}
public virtual string Name { get; set; }
}
}
}
5 changes: 2 additions & 3 deletions Reinforced.Typings/Attributes/TsEnumAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Reinforced.Typings.Attributes
{
/// <summary>
/// Exports enum as TypeScript Enum
/// Exports enum as TypeScript Enum
/// </summary>
[AttributeUsage(AttributeTargets.Enum)]
public class TsEnumAttribute : TsDeclarationAttributeBase
{

}
}
}
26 changes: 26 additions & 0 deletions Reinforced.Typings/Attributes/TsFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;

namespace Reinforced.Typings.Attributes
{
/// <summary>
/// Specifies file where to put generated code for type.
/// This attribute is being ignored when RtDivideTypesAmongFiles is false.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum)]
public class TsFile : Attribute
{
/// <summary>
/// Constructs new TsFile attribute
/// </summary>
/// <param name="fileName">File name (related to RtTargetDirectory) where to put generated code</param>
public TsFile(string fileName)
{
FileName = fileName;
}

/// <summary>
/// File name (related to RtTargetDirectory) where to put generated code
/// </summary>
public string FileName { get; set; }
}
}
Loading

0 comments on commit 0356c38

Please sign in to comment.