Skip to content

Commit b726ad0

Browse files
committed
Was made refactoring
1 parent e21b77d commit b726ad0

File tree

11 files changed

+726
-556
lines changed

11 files changed

+726
-556
lines changed

src/MsieJavaScriptEngine.Net4/MsieJavaScriptEngine.Net40.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@
5454
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\ActiveScriptJsEngineBase.ScriptSite.cs">
5555
<Link>ActiveScript\ActiveScriptJsEngineBase.ScriptSite.cs</Link>
5656
</Compile>
57-
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\ActiveScriptWrapper.cs">
58-
<Link>ActiveScript\ActiveScriptWrapper.cs</Link>
57+
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\ActiveScriptWrapper32.cs">
58+
<Link>ActiveScript\ActiveScriptWrapper32.cs</Link>
59+
</Compile>
60+
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\ActiveScriptWrapper64.cs">
61+
<Link>ActiveScript\ActiveScriptWrapper64.cs</Link>
62+
</Compile>
63+
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\ActiveScriptWrapperBase.cs">
64+
<Link>ActiveScript\ActiveScriptWrapperBase.cs</Link>
5965
</Compile>
6066
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\ChakraActiveScriptJsEngine.cs">
6167
<Link>ActiveScript\ChakraActiveScriptJsEngine.cs</Link>
@@ -249,6 +255,9 @@
249255
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\IActiveScriptSite.cs">
250256
<Link>ActiveScript\IActiveScriptSite.cs</Link>
251257
</Compile>
258+
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\IActiveScriptWrapper.cs">
259+
<Link>ActiveScript\IActiveScriptWrapper.cs</Link>
260+
</Compile>
252261
<Compile Include="..\MsieJavaScriptEngine\ActiveScript\ScriptGCType.cs">
253262
<Link>ActiveScript\ScriptGCType.cs</Link>
254263
</Compile>

src/MsieJavaScriptEngine/ActiveScript/ActiveScriptException.cs

Lines changed: 28 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#if !NETSTANDARD1_3
22
using System;
3-
using System.Runtime.InteropServices.ComTypes;
43
using System.Runtime.Serialization;
54
using System.Security.Permissions;
65

@@ -15,19 +14,19 @@ public sealed class ActiveScriptException : Exception
1514
private int _errorCode;
1615

1716
/// <summary>
18-
/// WCode
17+
/// Category of error
1918
/// </summary>
20-
private short _errorWCode;
19+
private string _category = string.Empty;
2120

2221
/// <summary>
23-
/// Application specific source context
22+
/// Description of error
2423
/// </summary>
25-
private uint _sourceContext;
24+
private string _description = string.Empty;
2625

2726
/// <summary>
28-
/// Subcategory of error
27+
/// Application specific source context
2928
/// </summary>
30-
private string _subcategory = string.Empty;
29+
private uint _sourceContext;
3130

3231
/// <summary>
3332
/// Line number on which the error occurred
@@ -42,7 +41,7 @@ public sealed class ActiveScriptException : Exception
4241
/// <summary>
4342
/// Content of the line on which the error occurred
4443
/// </summary>
45-
private string _sourceError = string.Empty;
44+
private string _sourceFragment = string.Empty;
4645

4746
/// <summary>
4847
/// Gets or sets a error code
@@ -54,30 +53,30 @@ public int ErrorCode
5453
}
5554

5655
/// <summary>
57-
/// Gets or sets a WCode
56+
/// Gets or sets a category of error
5857
/// </summary>
59-
public short ErrorWCode
58+
public string Category
6059
{
61-
get { return _errorWCode; }
62-
set { _errorWCode = value; }
60+
get { return _category; }
61+
set { _category = value; }
6362
}
6463

6564
/// <summary>
66-
/// Gets or sets a application specific source context
65+
/// Gets or sets a description of error
6766
/// </summary>
68-
public uint SourceContext
67+
public string Description
6968
{
70-
get { return _sourceContext; }
71-
set { _sourceContext = value; }
69+
get { return _description; }
70+
set { _description = value; }
7271
}
7372

7473
/// <summary>
75-
/// Gets or sets a subcategory of error
74+
/// Gets or sets a application specific source context
7675
/// </summary>
77-
public string Subcategory
76+
public uint SourceContext
7877
{
79-
get { return _subcategory; }
80-
set { _subcategory = value; }
78+
get { return _sourceContext; }
79+
set { _sourceContext = value; }
8180
}
8281

8382
/// <summary>
@@ -101,10 +100,10 @@ public int ColumnNumber
101100
/// <summary>
102101
/// Gets or sets a content of the line on which the error occurred
103102
/// </summary>
104-
public string SourceError
103+
public string SourceFragment
105104
{
106-
get { return _sourceError; }
107-
set { _sourceError = value; }
105+
get { return _sourceFragment; }
106+
set { _sourceFragment = value; }
108107
}
109108

110109

@@ -139,83 +138,13 @@ private ActiveScriptException(SerializationInfo info, StreamingContext context)
139138
if (info != null)
140139
{
141140
_errorCode = info.GetInt32("ErrorCode");
142-
_errorWCode = info.GetInt16("ErrorWCode");
141+
_category = info.GetString("Category");
142+
_description = info.GetString("Description");
143143
_sourceContext = info.GetUInt32("SourceContext");
144-
_subcategory = info.GetString("Subcategory");
145144
_lineNumber = info.GetUInt32("LineNumber");
146145
_columnNumber = info.GetInt32("ColumnNumber");
147-
_sourceError = info.GetString("SourceError");
148-
}
149-
}
150-
151-
152-
internal static ActiveScriptException Create(string message, IActiveScriptError error)
153-
{
154-
int errorCode = 0;
155-
short errorWCode = 0;
156-
uint sourceContext = 0;
157-
string subcategory = string.Empty;
158-
string helpLink = string.Empty;
159-
uint lineNumber = 0;
160-
int columnNumber = 0;
161-
string sourceError = string.Empty;
162-
163-
try
164-
{
165-
error.GetSourceLineText(out sourceError);
166-
}
167-
catch
168-
{
169-
// Do nothing
170-
}
171-
172-
try
173-
{
174-
error.GetSourcePosition(out sourceContext, out lineNumber, out columnNumber);
175-
++lineNumber;
176-
++columnNumber;
177-
}
178-
catch
179-
{
180-
// Do nothing
181-
}
182-
183-
try
184-
{
185-
EXCEPINFO excepInfo;
186-
error.GetExceptionInfo(out excepInfo);
187-
188-
subcategory = excepInfo.bstrSource;
189-
errorCode = excepInfo.scode;
190-
errorWCode = excepInfo.wCode;
191-
if (!string.IsNullOrWhiteSpace(excepInfo.bstrHelpFile)
192-
&& excepInfo.dwHelpContext != 0)
193-
{
194-
helpLink = string.Format("{0}: {1}", excepInfo.bstrHelpFile, excepInfo.dwHelpContext);
195-
}
196-
else if (!string.IsNullOrWhiteSpace(excepInfo.bstrHelpFile))
197-
{
198-
helpLink = excepInfo.bstrHelpFile;
199-
}
146+
_sourceFragment = info.GetString("SourceFragment");
200147
}
201-
catch
202-
{
203-
// Do nothing
204-
}
205-
206-
var activeScriptException = new ActiveScriptException(message)
207-
{
208-
ErrorCode = errorCode,
209-
ErrorWCode = errorWCode,
210-
SourceContext = sourceContext,
211-
Subcategory = subcategory,
212-
LineNumber = lineNumber,
213-
ColumnNumber = columnNumber,
214-
SourceError = sourceError,
215-
HelpLink = helpLink,
216-
};
217-
218-
return activeScriptException;
219148
}
220149

221150
#region Exception overrides
@@ -235,12 +164,12 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
235164

236165
base.GetObjectData(info, context);
237166
info.AddValue("ErrorCode", _errorCode);
238-
info.AddValue("ErrorWCode", _errorWCode);
167+
info.AddValue("Category", _category);
168+
info.AddValue("Description", _description);
239169
info.AddValue("SourceContext", _sourceContext);
240-
info.AddValue("Subcategory", _subcategory);
241170
info.AddValue("LineNumber", _lineNumber);
242171
info.AddValue("ColumnNumber", _columnNumber);
243-
info.AddValue("SourceError", _sourceError);
172+
info.AddValue("SourceFragment", _sourceFragment);
244173
}
245174

246175
#endregion

0 commit comments

Comments
 (0)