-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Visual Studio-friendly warning and error messages - Extracting types information from .exe assemblies - Initialization expression for fields AST - Assembly signing
- Loading branch information
1 parent
883e2a9
commit 0912c25
Showing
35 changed files
with
614 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,3 +203,4 @@ FakesAssemblies/ | |
*.opt | ||
Playground/ | ||
/Reinforced.Typings.Private.sln | ||
/Reinforced.Typings/Reinforced.Typings.pfx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Reinforced.Typings.Cli/VisualStudioFriendlyErrorMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Reinforced.Typings.Exceptions; | ||
|
||
namespace Reinforced.Typings.Cli | ||
{ | ||
/// <summary> | ||
/// Class that formats messages in appropriate way to be shown at | ||
/// VisualStudio's errors list | ||
/// | ||
/// Explanation is taken from here: | ||
/// http://blogs.msdn.com/b/msbuild/archive/2006/11/03/msbuild-visual-studio-aware-error-messages-and-message-formats.aspx | ||
/// </summary> | ||
class VisualStudioFriendlyErrorMessage | ||
{ | ||
public string Origin { get { return "Reinforced.Typings"; } } | ||
|
||
public string Subcategory { get; set; } | ||
|
||
public VisualStudioFriendlyMessageType Type { get; set; } | ||
|
||
public int Code { get; set; } | ||
|
||
public string CodeName { get { return string.Format("RT{0:0000}", Code); } } | ||
|
||
public string ErrorText { get; set; } | ||
|
||
public VisualStudioFriendlyErrorMessage(int code, string errorText, VisualStudioFriendlyMessageType type, string subcategory = "") | ||
{ | ||
Code = code; | ||
ErrorText = errorText; | ||
Subcategory = subcategory; | ||
Type = type; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return string.Format("{0} : {1} {2} {3}: {4}", Origin, Subcategory, Type == VisualStudioFriendlyMessageType.Error ? "error" : "warning", CodeName, ErrorText); | ||
} | ||
|
||
public static VisualStudioFriendlyErrorMessage Create(RtWarning warning) | ||
{ | ||
return new VisualStudioFriendlyErrorMessage(warning.Code,warning.Text,VisualStudioFriendlyMessageType.Warning,warning.Subcategory); | ||
} | ||
|
||
public static VisualStudioFriendlyErrorMessage Create(RtException error) | ||
{ | ||
return new VisualStudioFriendlyErrorMessage(error.Code, error.Message, VisualStudioFriendlyMessageType.Error, error.Subcategory); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Reinforced.Typings.Cli | ||
{ | ||
public enum VisualStudioFriendlyMessageType | ||
{ | ||
Error, | ||
Warning | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Reinforced.Typings.Exceptions | ||
{ | ||
class ErrorMessage | ||
{ | ||
public int Code { get; private set; } | ||
|
||
public string MessageText { get; private set; } | ||
|
||
public string Subcategory { get; private set; } | ||
|
||
public ErrorMessage(int code, string messageText, string subcategory = "") | ||
{ | ||
Code = code; | ||
MessageText = messageText; | ||
Subcategory = subcategory; | ||
} | ||
|
||
public void Throw(params object[] formatParameters) | ||
{ | ||
throw new RtException(string.Format(MessageText, formatParameters), Code, Subcategory); | ||
} | ||
|
||
public RtWarning Warn(params object[] formatParameters) | ||
{ | ||
return new RtWarning(Code, text: string.Format(MessageText, formatParameters), subcategory: Subcategory); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Reinforced.Typings.Exceptions | ||
{ | ||
/// <summary> | ||
/// This class contains all RT's error and siagnostic messages. | ||
/// Why didnt I use resources? I dont want to add one more .dll to RT's NuGet package. | ||
/// if localization will be required through issues then I will add one | ||
/// </summary> | ||
class ErrorMessages | ||
{ | ||
#region Errors | ||
/// <summary> | ||
/// Could not acuire temorary file {0}: {1} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0001_TempFileError = new ErrorMessage(0001,"Could not acuire temorary file {0}: {1}","IO"); | ||
|
||
/// <summary> | ||
/// Could not replace source file {0}: {1} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0002_DeployingFilesError = new ErrorMessage(0002,"Could not replace source file {0}: {1}","IO"); | ||
|
||
/// <summary> | ||
/// Could not instantiate code generator {0}: {1} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0003_GeneratorInstantiate = new ErrorMessage(0003,"Could not instantiate code generator {0}: {1}","Code generation"); | ||
|
||
/// <summary> | ||
/// Code generator {0} has thrown an error: {1} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0004_GeneratorError = new ErrorMessage(0004,"Code generator {0} has thrown an error: {1}","Code generation"); | ||
|
||
/// <summary> | ||
/// Could not resolve type for {0}. An error occured: {1} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0005_TypeResolvationError = new ErrorMessage(0005, "Could not resolve type for {0}. An error occured: {1}", "Type resolvation"); | ||
|
||
/// <summary> | ||
/// Exception thrown when applying fluent configuration method for {1} '{2}': {0} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0006_FluentSingleError = new ErrorMessage(0006, "Exception thrown when applying fluent configuration method for {1} '{2}': {0}", "Fluent configuration"); | ||
|
||
/// <summary> | ||
/// Exception thrown when applying fluent configuration method for collection of {1}: {0} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0007_FluentBatchError = new ErrorMessage(0007, "Exception thrown when applying fluent configuration method for collection of {1}: {0}", "Fluent configuration"); | ||
|
||
/// <summary> | ||
/// MethodCallExpression should be provided for .WithMethod call. Please use only lamba expressions in this place. | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0008_FluentWithMethodError = new ErrorMessage(0008, "MethodCallExpression should be provided for .WithMethod call. Please use only lamba expressions in this place.", "Fluent configuration"); | ||
|
||
|
||
/// <summary> | ||
/// Sorry, but {0} is not very good idea for parameter configuration. Try using simplier lambda expression. | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0009_FluentWithMethodCouldNotParse = new ErrorMessage(0009, "Sorry, but {0} is not very good idea for parameter configuration. Try using simplier lambda expression.", "Fluent configuration"); | ||
|
||
/// <summary> | ||
/// Property lambda expression expected in {0} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0010_PropertyLambdaExpected = new ErrorMessage(0010, "Property lambda expression expected in {0}", "Fluent configuration"); | ||
|
||
/// <summary> | ||
/// Field lambda expression expected in {0} | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0011_FieldLambdaExpected = new ErrorMessage(0011, "Field lambda expression expected in {0}", "Fluent configuration"); | ||
|
||
/// <summary> | ||
/// NewExpression should be provided for .WithConstructor call. Please use only lamba expressions in this place. | ||
/// </summary> | ||
public static readonly ErrorMessage RTE0012_NewExpressionLambdaExpected = new ErrorMessage(0012, "NewExpression should be provided for .WithConstructor call. Please use only 'new ...' lamba expressions in this place.", "Fluent configuration"); | ||
#endregion | ||
|
||
#region Warnings | ||
/// <summary> | ||
/// XMLDOC file not supplied | ||
/// </summary> | ||
public static readonly ErrorMessage RTW0001_DocumentationNotSupplied = new ErrorMessage(0001, "XMLDOC file not supplied", "JSDOC"); | ||
|
||
/// <summary> | ||
/// Could not find XMLDOC file {0} | ||
/// </summary> | ||
public static readonly ErrorMessage RTW0002_DocumentationNotFound = new ErrorMessage(0002, "Could not find XMLDOC file {0}", "JSDOC"); | ||
|
||
/// <summary> | ||
/// Could not find suitable TypeScript type for {0}. 'any' assumed. | ||
/// </summary> | ||
public static readonly ErrorMessage RTW0003_TypeUnknown = new ErrorMessage(0003, "Could not find suitable TypeScript type for {0}. 'any' assumed.", "Type resolvation"); | ||
|
||
/// <summary> | ||
/// No suitable base constructor found for {0}. Generating 'super' call with all nulls. | ||
/// </summary> | ||
public static readonly ErrorMessage RTW0004_DefaultSuperCall = new ErrorMessage(0004, "No suitable base constructor found for {0}. Generating 'super' call with all nulls.", "Class code generation"); | ||
|
||
/// <summary> | ||
/// Class {0} (base for {1}) is exported as interface. It is potentially unsafe facility. | ||
/// </summary> | ||
public static readonly ErrorMessage RTW0005_BaseClassExportingAsInterface = new ErrorMessage(0005, "Class {0} (base for {1}) is exported as interface. It is potentially unsafe facility.", "Class code generation"); | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Reinforced.Typings.Exceptions | ||
{ | ||
/// <summary> | ||
/// Base class for RT exception. | ||
/// All the RT exceptions will be provided to VisualStudio's errors tab | ||
/// </summary> | ||
public class RtException : Exception | ||
{ | ||
/// <summary> | ||
/// Internal error code | ||
/// </summary> | ||
public int Code { get; private set; } | ||
|
||
/// <summary> | ||
/// Error subcategory | ||
/// </summary> | ||
public string Subcategory { get; private set; } | ||
|
||
/// <summary> | ||
/// Constructs new RT exception | ||
/// </summary> | ||
/// <param name="message">Error message</param> | ||
/// <param name="code">Error code</param> | ||
/// <param name="subcategory">Error subcategory (optional)</param> | ||
public RtException(string message, int code, string subcategory = "") : base(message) | ||
{ | ||
Code = code; | ||
Subcategory = subcategory; | ||
} | ||
} | ||
} |
Oops, something went wrong.