fix(ab-transport): widen libplctag guard regex to catch aliases and static usings
This commit is contained in:
+12
-1
@@ -7,7 +7,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport.Tests;
|
||||
public sealed class LibplctagConfinementGuardTests
|
||||
{
|
||||
private static readonly Regex Reference = new(
|
||||
@"\busing\s+libplctag\b|\blibplctag\.(Tag|Status|PlcType|Protocol|LibPlcTagException|NativeImport)\b",
|
||||
@"\busing\s+(static\s+)?(\w+\s*=\s*)?libplctag\b|\blibplctag\.[A-Z]",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
[Fact]
|
||||
@@ -43,4 +43,15 @@ public sealed class LibplctagConfinementGuardTests
|
||||
var prose = "via libplctag. Second of six driver CLIs";
|
||||
Reference.IsMatch(prose).ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("using libplctag;")]
|
||||
[InlineData("global using libplctag;")]
|
||||
[InlineData("using static libplctag.NativeImport.plctag;")]
|
||||
[InlineData("using T = libplctag.Tag;")]
|
||||
[InlineData("var x = new libplctag.DataTypes.DintPlcMapper();")]
|
||||
public void Code_references_trip_the_guard(string code)
|
||||
{
|
||||
Reference.IsMatch(code).ShouldBeTrue($"regex should match: {code}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user