Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 1198263

Browse files
authored
Merge pull request #41 from episerver/bugfix/40-partial-router
Fixed issue with out of range exception in partial route rewrite
2 parents affe52e + 7cf2cf0 commit 1198263

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/EpiSourceUpdater/EpiPartialRouterAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public sealed class EpiPartialRouterAnalyzer : EpiSubTypeAnalyzer
2828
private const string Category = "Upgrade";
2929

3030

31-
private static readonly string MethodName = "RoutePartial";
31+
private static readonly string MethodName = "GetPartialVirtualPath";
3232
private static readonly string RegistrationMethod = "RegisterPartialRouter";
3333
private static readonly string[] BaseTypes = new[] { "IPartialRouter" };
3434

@@ -75,7 +75,7 @@ private void AnalyzeIfInterfaceMethod(SyntaxNodeAnalysisContext context)
7575
if (namespaceName.Equals(MethodName, StringComparison.Ordinal))
7676
{
7777
var parameters = methodDirective.ParameterList.Parameters;
78-
if (IsSubType(methodDirective.Parent as ClassDeclarationSyntax))
78+
if (IsSubType(methodDirective.Parent as ClassDeclarationSyntax) && parameters.Count == 4)
7979
{
8080
var diagnostic = Diagnostic.Create(Rule, methodDirective.Parent.GetLocation(), methodDirective.ToFullString());
8181
context.ReportDiagnostic(diagnostic);

src/EpiSourceUpdater/EpiPartialRouterCodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ private static async Task<Document> ReplaceParametersAsync(Document document, Cl
7676
var parameters = routePartialMethod.ParameterList.Parameters;
7777
var obsoleteParameter = routePartialMethod.ParameterList.Parameters[1];
7878
parameters = parameters.Remove(obsoleteParameter);
79-
parameters = parameters.Add(obsoleteParameter.WithType(SyntaxFactory.ParseTypeName("UrlResolverContext")));
79+
parameters = parameters.Add(obsoleteParameter.WithType(SyntaxFactory.ParseTypeName("UrlResolverContext").WithTrailingTrivia(SyntaxFactory.Whitespace(" "))));
8080
var updatedMethod = routePartialMethod.WithParameterList(SyntaxFactory.ParameterList(parameters));
8181

8282
var newRoot = root.ReplaceNode(routePartialMethod, updatedMethod);
8383
var updatedDocument = document.WithSyntaxRoot(newRoot);
84-
localDeclaration = newRoot.FindNode(localDeclaration.Span) as ClassDeclarationSyntax;
84+
localDeclaration = newRoot.FindNode(localDeclaration.Identifier.Span) as ClassDeclarationSyntax;
8585

8686
var virtualPathMethod = FindMethod(localDeclaration, "GetPartialVirtualPath");
8787
parameters = virtualPathMethod.ParameterList.Parameters;

0 commit comments

Comments
 (0)