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

Commit

Permalink
Do not generate C# line pragmas without a file path.
Browse files Browse the repository at this point in the history
- Prior to this change default imports would get line pragmas generated for them because thye'd have a source location but no file path (they were a dynamic document).
- Re-generated C# files to reflect new line pragma changes.

#1110
  • Loading branch information
NTaylorMullen committed Apr 4, 2017
1 parent c7e2e18 commit dda9cf3
Show file tree
Hide file tree
Showing 30 changed files with 170 additions and 607 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@ public CSharpCodeWritingScope BuildMethodDeclaration(string accessibility, strin

public IDisposable BuildLinePragma(SourceSpan documentLocation)
{
if (string.IsNullOrEmpty(documentLocation.FilePath))
{
// Can't build a valid line pragma without a file path.
return NullDisposable.Default;
}

return new LinePragmaWriter(this, documentLocation);
}

Expand Down Expand Up @@ -632,5 +638,18 @@ public void Dispose()
.SetIndent(_startIndent);
}
}

private class NullDisposable : IDisposable
{
public static readonly NullDisposable Default = new NullDisposable();

private NullDisposable()
{
}

public void Dispose()
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@ namespace AspNetCore
{
#line hidden
using TModel = global::System.Object;
#line 1 ""
using System;

#line default
#line hidden
using System;
using System.Threading.Tasks;
#line 2 ""
using System.Linq;

#line default
#line hidden
#line 3 ""
using System.Collections.Generic;

#line default
#line hidden
#line 4 ""
using Microsoft.AspNetCore.Mvc;

#line default
#line hidden
#line 5 ""
using Microsoft.AspNetCore.Mvc.Rendering;

#line default
#line hidden
#line 6 ""
using Microsoft.AspNetCore.Mvc.ViewFeatures;

#line default
#line hidden
using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
public class _TestFiles_Input_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
{
#pragma warning disable 219
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Source Location: (13:0,13 [4] /TestFiles/Input/Basic.cshtml)
|logo|
Generated Location: (1063:46,13 [4] )
Generated Location: (829:22,13 [4] )
|logo|

Source Location: (43:2,5 [21] /TestFiles/Input/Basic.cshtml)
|Html.Input("SomeKey")|
Generated Location: (1148:51,6 [21] )
Generated Location: (914:27,6 [21] )
|Html.Input("SomeKey")|

Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@ namespace AspNetCore
{
#line hidden
using TModel = global::System.Object;
#line 1 ""
using System;

#line default
#line hidden
using System;
using System.Threading.Tasks;
#line 2 ""
using System.Linq;

#line default
#line hidden
#line 3 ""
using System.Collections.Generic;

#line default
#line hidden
#line 4 ""
using Microsoft.AspNetCore.Mvc;

#line default
#line hidden
#line 5 ""
using Microsoft.AspNetCore.Mvc.Rendering;

#line default
#line hidden
#line 6 ""
using Microsoft.AspNetCore.Mvc.ViewFeatures;

#line default
#line hidden
using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
#line 1 "/TestFiles/Input/Inject.cshtml"
using MyNamespace;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Source Location: (1:0,1 [17] /TestFiles/Input/Inject.cshtml)
|using MyNamespace|
Generated Location: (613:36,0 [17] )
Generated Location: (379:12,0 [17] )
|using MyNamespace|

Source Location: (28:1,8 [5] /TestFiles/Input/Inject.cshtml)
|MyApp|
Generated Location: (908:45,0 [5] )
Generated Location: (674:21,0 [5] )
|MyApp|

Source Location: (34:1,14 [14] /TestFiles/Input/Inject.cshtml)
|MyPropertyName|
Generated Location: (1010:49,14 [14] )
Generated Location: (776:25,14 [14] )
|MyPropertyName|

Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@ namespace AspNetCore
{
#line hidden
using TModel = MyModel;
#line 1 ""
using System;

#line default
#line hidden
using System;
using System.Threading.Tasks;
#line 2 ""
using System.Linq;

#line default
#line hidden
#line 3 ""
using System.Collections.Generic;

#line default
#line hidden
#line 4 ""
using Microsoft.AspNetCore.Mvc;

#line default
#line hidden
#line 5 ""
using Microsoft.AspNetCore.Mvc.Rendering;

#line default
#line hidden
#line 6 ""
using Microsoft.AspNetCore.Mvc.ViewFeatures;

#line default
#line hidden
using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
public class _TestFiles_Input_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel>
{
#pragma warning disable 219
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
Source Location: (7:0,7 [7] /TestFiles/Input/InjectWithModel.cshtml)
|MyModel|
Generated Location: (810:40,0 [7] )
Generated Location: (576:16,0 [7] )
|MyModel|

Source Location: (24:1,8 [5] /TestFiles/Input/InjectWithModel.cshtml)
|MyApp|
Generated Location: (900:44,0 [5] )
Generated Location: (666:20,0 [5] )
|MyApp|

Source Location: (30:1,14 [14] /TestFiles/Input/InjectWithModel.cshtml)
|MyPropertyName|
Generated Location: (1002:48,14 [14] )
Generated Location: (768:24,14 [14] )
|MyPropertyName|

Source Location: (54:2,8 [17] /TestFiles/Input/InjectWithModel.cshtml)
|MyService<TModel>|
Generated Location: (1086:52,0 [17] )
Generated Location: (852:28,0 [17] )
|MyService<TModel>|

Source Location: (72:2,26 [4] /TestFiles/Input/InjectWithModel.cshtml)
|Html|
Generated Location: (1200:56,14 [4] )
Generated Location: (966:32,14 [4] )
|Html|

Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@ namespace AspNetCore
{
#line hidden
using TModel = MyModel;
#line 1 ""
using System;

#line default
#line hidden
using System;
using System.Threading.Tasks;
#line 2 ""
using System.Linq;

#line default
#line hidden
#line 3 ""
using System.Collections.Generic;

#line default
#line hidden
#line 4 ""
using Microsoft.AspNetCore.Mvc;

#line default
#line hidden
#line 5 ""
using Microsoft.AspNetCore.Mvc.Rendering;

#line default
#line hidden
#line 6 ""
using Microsoft.AspNetCore.Mvc.ViewFeatures;

#line default
#line hidden
using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
public class _TestFiles_Input_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel>
{
#pragma warning disable 219
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
Source Location: (7:0,7 [7] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyModel|
Generated Location: (814:40,0 [7] )
Generated Location: (580:16,0 [7] )
|MyModel|

Source Location: (24:1,8 [5] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyApp|
Generated Location: (904:44,0 [5] )
Generated Location: (670:20,0 [5] )
|MyApp|

Source Location: (30:1,14 [14] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyPropertyName|
Generated Location: (1006:48,14 [14] )
Generated Location: (772:24,14 [14] )
|MyPropertyName|

Source Location: (58:2,8 [17] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyService<TModel>|
Generated Location: (1090:52,0 [17] )
Generated Location: (856:28,0 [17] )
|MyService<TModel>|

Source Location: (76:2,26 [4] /TestFiles/Input/InjectWithSemicolon.cshtml)
|Html|
Generated Location: (1204:56,14 [4] )
Generated Location: (970:32,14 [4] )
|Html|

Source Location: (93:3,8 [5] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyApp|
Generated Location: (1278:60,0 [5] )
Generated Location: (1044:36,0 [5] )
|MyApp|

Source Location: (99:3,14 [15] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyPropertyName2|
Generated Location: (1380:64,14 [15] )
Generated Location: (1146:40,14 [15] )
|MyPropertyName2|

Source Location: (129:4,8 [17] /TestFiles/Input/InjectWithSemicolon.cshtml)
|MyService<TModel>|
Generated Location: (1465:68,0 [17] )
Generated Location: (1231:44,0 [17] )
|MyService<TModel>|

Source Location: (147:4,26 [5] /TestFiles/Input/InjectWithSemicolon.cshtml)
|Html2|
Generated Location: (1579:72,14 [5] )
Generated Location: (1345:48,14 [5] )
|Html2|

Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@ namespace AspNetCore
{
#line hidden
using TModel = System.Collections.IEnumerable;
#line 1 ""
using System;

#line default
#line hidden
using System;
using System.Threading.Tasks;
#line 2 ""
using System.Linq;

#line default
#line hidden
#line 3 ""
using System.Collections.Generic;

#line default
#line hidden
#line 4 ""
using Microsoft.AspNetCore.Mvc;

#line default
#line hidden
#line 5 ""
using Microsoft.AspNetCore.Mvc.Rendering;

#line default
#line hidden
#line 6 ""
using Microsoft.AspNetCore.Mvc.ViewFeatures;

#line default
#line hidden
using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
public class _TestFiles_Input_Model_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<System.Collections.IEnumerable>
{
#pragma warning disable 219
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source Location: (7:0,7 [30] /TestFiles/Input/Model.cshtml)
|System.Collections.IEnumerable|
Generated Location: (846:40,0 [30] )
Generated Location: (612:16,0 [30] )
|System.Collections.IEnumerable|

Loading

0 comments on commit dda9cf3

Please sign in to comment.