Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Threading.Tasks;
using ReferenceCopAnalyzer.Test.Verifiers;
using Xunit;

namespace ReferenceCopAnalyzer.Test
{
public class NamedWildcardsTests
{
private const string Src = $@"
namespace One.Contracts {{
}}
namespace One.Contracts.Internal {{
}}
namespace Two {{
using One.Contracts.Internal;
using One.Contracts;
}}
namespace One.B.C {{
using One.Contracts.Internal;
}}
";

[Theory]
[InlineData(Src, @"* *
!* *.Contracts.Internal
[context].* [context].Contracts.Internal", new[] { "Two", "One.Contracts.Internal" })]
public async Task ShouldReportIllegalReference(
string source,
string rules,
object[] arguments)
{
await ReferenceCopAnalyzerVerifier.VerifyReferenceCopAnalysis(source, rules, new[]
{
ReferenceCopAnalyzerVerifier
.Diagnostic(ReferenceCopAnalyzer.ReferenceNotAllowedDiagnosticId)
.WithSpan(7, 5, 7, 34)
.WithArguments(arguments)
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private static bool IsAllowedReference(List<KeyValuePair<string, string>> allowe
}

// Build the mappings based on the sourceName
foreach (Match match in Regex.Matches(sourceName, WildCardToRegular(ruleSource)))
foreach (Match match in Regex.Matches(sourceName, WildCardToRegular(ruleSource), RegexOptions.RightToLeft))
{
bool first = true;
foreach (Group matchGroup in match.Groups)
Expand Down