Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Fix #1355 Make extension nodes check for their extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
rynowak committed Jun 9, 2017
1 parent e05c697 commit 17800b6
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@ public override void WriteNode(CodeTarget target, CSharpRenderingContext context
throw new ArgumentNullException(nameof(target));
}

if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

var extension = target.GetExtension<IInjectDirectiveTargetExtension>();
if (extension == null)
{
context.ReportMissingExtension<IInjectDirectiveTargetExtension>();
return;
}

extension.WriteInjectProperty(context, this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public override void Accept(RazorIRNodeVisitor visitor)

public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}

if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

var extension = target.GetExtension<ITemplateTargetExtension>();
if (extension == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,23 @@ public override void Accept(RazorIRNodeVisitor visitor)

public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}

if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
if (extension == null)
{
context.ReportMissingExtension<IPreallocatedAttributeTargetExtension>();
return;
}

extension.WriteAddPreallocatedTagHelperHtmlAttribute(context, this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,23 @@ public override void Accept(RazorIRNodeVisitor visitor)

public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}

if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
if (extension == null)
{
context.ReportMissingExtension<IPreallocatedAttributeTargetExtension>();
return;
}

extension.WriteDeclarePreallocatedTagHelperAttribute(context, this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,23 @@ public override void Accept(RazorIRNodeVisitor visitor)

public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}

if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
if (extension == null)
{
context.ReportMissingExtension<IPreallocatedAttributeTargetExtension>();
return;
}

extension.WriteDeclarePreallocatedTagHelperHtmlAttribute(context, this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,23 @@ public override void Accept(RazorIRNodeVisitor visitor)

public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}

if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

var extension = target.GetExtension<IDesignTimeDirectiveTargetExtension>();
if (extension == null)
{
context.ReportMissingExtension<IDesignTimeDirectiveTargetExtension>();
return;
}

extension.WriteDesignTimeDirective(context, this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,23 @@ public override void Accept(RazorIRNodeVisitor visitor)

public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}

if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
if (extension == null)
{
context.ReportMissingExtension<IPreallocatedAttributeTargetExtension>();
return;
}

extension.WriteSetPreallocatedTagHelperProperty(context, this);
}
}
Expand Down

0 comments on commit 17800b6

Please sign in to comment.