Skip to content

Commit 21d2f8a

Browse files
committed
Merge branch 'hotfix/fix-components-19'
2 parents 7a3aafd + ba89298 commit 21d2f8a

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

install/opm-0.13.0.ospx

1.92 KB
Binary file not shown.

src/NUnitTests/TestContextClass.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ namespace NUnitTests
1414
public class TestContextClass : AutoContext<TestContextClass>
1515
{
1616

17-
[ContextMethod("УстаревшийМетод", "ObsoleteMethod", isDeprecated: true)]
17+
[ContextMethod("УстаревшийМетод", "ObsoleteMethod", IsDeprecated = true, ThrowOnUse = false)]
1818
public void ObsoleteMethod()
1919
{
2020
// Do nothing
2121
}
2222

2323
[ContextMethod("ХорошийМетод", "GoodMethod")]
24-
[ContextMethod("ObsoleteAlias", isDeprecated: true)]
25-
[ContextMethod("VeryObsoleteAlias", isDeprecated: true, throwOnUse: true)]
24+
[ContextMethod("ObsoleteAlias", IsDeprecated = true, ThrowOnUse = false)]
25+
[ContextMethod("VeryObsoleteAlias", IsDeprecated = true, ThrowOnUse = true)]
2626
public void GoodMethod()
2727
{
2828
// Do nothing

src/ScriptEngine.HostedScript/Library/SystemGlobalContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ public bool ValueIsFilled(IValue inValue)
482482

483483
}
484484

485-
[ContextMethod("IsValueFilled", null, isDeprecated: true)]
485+
[ContextMethod("IsValueFilled", IsDeprecated = true, ThrowOnUse = false)]
486486
[Obsolete]
487487
public bool IsValueFilled(IValue value)
488488
{

src/ScriptEngine/Machine/Contexts/ContextMethodMapper.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ContextMethodAttribute : Attribute
1616
private readonly string _name;
1717
private readonly string _alias;
1818

19-
public ContextMethodAttribute(string name, string alias = null, bool isDeprecated = false, bool throwOnUse = false)
19+
public ContextMethodAttribute(string name, string alias = null)
2020
{
2121
if(!Utils.IsValidIdentifier(name))
2222
throw new ArgumentException("Name must be a valid identifier");
@@ -26,13 +26,6 @@ public ContextMethodAttribute(string name, string alias = null, bool isDeprecate
2626

2727
_name = name;
2828
_alias = alias;
29-
IsDeprecated = isDeprecated;
30-
ThrowOnUse = throwOnUse;
31-
}
32-
33-
public ContextMethodAttribute(string name, bool isDeprecated)
34-
: this(name, null, isDeprecated)
35-
{
3629
}
3730

3831
public string GetName()
@@ -45,9 +38,22 @@ public string GetAlias()
4538
return _alias;
4639
}
4740

48-
public bool IsDeprecated { get; }
41+
public string GetAlias(string nativeMethodName)
42+
{
43+
if (!string.IsNullOrEmpty(_alias))
44+
{
45+
return _alias;
46+
}
47+
if (!IsDeprecated)
48+
{
49+
return nativeMethodName;
50+
}
51+
return null;
52+
}
53+
54+
public bool IsDeprecated { get; set; }
4955

50-
public bool ThrowOnUse { get; }
56+
public bool ThrowOnUse { get; set; }
5157

5258
public bool IsFunction { get; set; }
5359
}
@@ -187,9 +193,7 @@ private void MapType(Type type)
187193
scriptMethInfo.IsDeprecated = item.Binding.IsDeprecated;
188194
scriptMethInfo.ThrowOnUseDeprecated = item.Binding.ThrowOnUse;
189195
scriptMethInfo.Name = item.Binding.GetName();
190-
scriptMethInfo.Alias = string.IsNullOrEmpty(item.Binding.GetAlias()) ?
191-
scriptMethInfo.Name
192-
:item.Binding.GetAlias();
196+
scriptMethInfo.Alias = item.Binding.GetAlias(item.Method.Name);
193197

194198
scriptMethInfo.Params = paramDefs;
195199

0 commit comments

Comments
 (0)