Revert "Merge branch 'dev' into rel/2.0.0"

This reverts commit 8ff9ef7b4c, reversing
changes made to c02d701e6e.
This commit is contained in:
Pranav K 2017-07-20 11:28:32 -07:00
parent 8ff9ef7b4c
commit 3f26451bc7
97 changed files with 284 additions and 2508 deletions

View File

@ -2,8 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
<add key="Roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-release/api/v3/index.json" />
<add key="AspNetCoreTools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>

View File

@ -1,4 +1,4 @@
init:
init:
- git config --global core.autocrlf true
branches:
only:
@ -10,10 +10,6 @@ branches:
build_script:
- ps: .\build.ps1
clone_depth: 1
environment:
global:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
test: off
deploy: off
os: Visual Studio 2017 Preview

View File

@ -33,7 +33,7 @@ cd $PSScriptRoot
$repoFolder = $PSScriptRoot
$env:REPO_FOLDER = $repoFolder
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip"
if ($env:KOREBUILD_ZIP)
{
$koreBuildZip=$env:KOREBUILD_ZIP

View File

@ -2,7 +2,7 @@
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $repoFolder
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip"
if [ ! -z $KOREBUILD_ZIP ]; then
koreBuildZip=$KOREBUILD_ZIP
fi

View File

@ -12,9 +12,6 @@
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
<VersionSuffix Condition="'$(VersionSuffix)'!='' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Generate full pdbs for desktop targeting projects on platforms that support generating full pdbs. -->
<DebugType Condition="'$(OS)'=='Windows_NT' AND '$(TargetFramework)'=='net46'">full</DebugType>
</PropertyGroup>
<ItemGroup>

View File

@ -12,7 +12,7 @@
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
<RoslynVersion>2.3.1</RoslynVersion>
<RoslynDevVersion>2.3.0-beta4-*</RoslynDevVersion>
<RoslynDevVersion>2.6.0-beta*</RoslynDevVersion>
<StreamJsonRpcVersion>1.1.92</StreamJsonRpcVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion>

View File

@ -29,10 +29,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
builder.Features.Add(new ViewComponentTagHelperPass());
builder.Features.Add(new RazorPageDocumentClassifierPass());
builder.Features.Add(new MvcViewDocumentClassifierPass());
builder.Features.Add(new AssemblyAttributeInjectionPass());
if (!builder.DesignTime)
{
builder.Features.Add(new AssemblyAttributeInjectionPass());
builder.Features.Add(new InstrumentationPass());
}
}

View File

@ -55,12 +55,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var factory = new ViewComponentTagHelperDescriptorFactory(compilation);
for (var i = 0; i < types.Count; i++)
{
var descriptor = factory.CreateDescriptor(types[i]);
if (descriptor != null)
{
context.Results.Add(descriptor);
}
context.Results.Add(factory.CreateDescriptor(types[i]));
}
}

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
}
protected override PartialParseResultInternal CanAcceptChange(Span target, SourceChange change)
protected override PartialParseResult CanAcceptChange(Span target, SourceChange change)
{
if (AcceptedCharacters == AcceptedCharactersInternal.NonWhiteSpace)
{
@ -25,11 +25,11 @@ namespace Microsoft.AspNetCore.Razor.Language
// Did not modify whitespace, directive format should be the same.
// Return provisional so extensible IR/code gen pieces can see the full directive text
// once the user stops editing the document.
return PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional;
return PartialParseResult.Accepted | PartialParseResult.Provisional;
}
}
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}

View File

@ -31,16 +31,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
public string AutoCompleteString { get; set; }
protected override PartialParseResultInternal CanAcceptChange(Span target, SourceChange change)
protected override PartialParseResult CanAcceptChange(Span target, SourceChange change)
{
if (((AutoCompleteAtEndOfSpan && IsAtEndOfSpan(target, change)) || IsAtEndOfFirstLine(target, change)) &&
change.IsInsert &&
ParserHelpers.IsNewLine(change.NewText) &&
AutoCompleteString != null)
{
return PartialParseResultInternal.Rejected | PartialParseResultInternal.AutoCompleteBlock;
return PartialParseResult.Rejected | PartialParseResult.AutoCompleteBlock;
}
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
public override string ToString()

View File

@ -5,13 +5,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{
internal class EditResult
{
public EditResult(PartialParseResultInternal result, SpanBuilder editedSpan)
public EditResult(PartialParseResult result, SpanBuilder editedSpan)
{
Result = result;
EditedSpan = editedSpan;
}
public PartialParseResultInternal Result { get; set; }
public PartialParseResult Result { get; set; }
public SpanBuilder EditedSpan { get; set; }
}
}

View File

@ -59,11 +59,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return hashCodeCombiner;
}
protected override PartialParseResultInternal CanAcceptChange(Span target, SourceChange change)
protected override PartialParseResult CanAcceptChange(Span target, SourceChange change)
{
if (AcceptedCharacters == AcceptedCharactersInternal.Any)
{
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
// In some editors intellisense insertions are handled as "dotless commits". If an intellisense selection is confirmed
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
// Don't support 0->1 length edits
if (lastChar == null)
{
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
// Accepts cases when insertions are made at the end of a span or '.' is inserted within a span.
@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return HandleDeletion(target, lastChar.Value, change);
}
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
// A dotless commit is the process of inserting a '.' with an intellisense selection.
@ -249,17 +249,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return string.IsNullOrWhiteSpace(target.Content.Substring(offset));
}
private PartialParseResultInternal HandleDotlessCommitInsertion(Span target)
private PartialParseResult HandleDotlessCommitInsertion(Span target)
{
var result = PartialParseResultInternal.Accepted;
var result = PartialParseResult.Accepted;
if (!AcceptTrailingDot && target.Content.LastOrDefault() == '.')
{
result |= PartialParseResultInternal.Provisional;
result |= PartialParseResult.Provisional;
}
return result;
}
private PartialParseResultInternal HandleReplacement(Span target, SourceChange change)
private PartialParseResult HandleReplacement(Span target, SourceChange change)
{
// Special Case for IntelliSense commits.
// When IntelliSense commits, we get two changes (for example user typed "Date", then committed "DateTime" by pressing ".")
@ -268,24 +268,24 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
// We need partial parsing to accept case #2.
var oldText = change.GetOriginalText(target);
var result = PartialParseResultInternal.Rejected;
var result = PartialParseResult.Rejected;
if (EndsWithDot(oldText) && EndsWithDot(change.NewText))
{
result = PartialParseResultInternal.Accepted;
result = PartialParseResult.Accepted;
if (!AcceptTrailingDot)
{
result |= PartialParseResultInternal.Provisional;
result |= PartialParseResult.Provisional;
}
}
return result;
}
private PartialParseResultInternal HandleDeletion(Span target, char previousChar, SourceChange change)
private PartialParseResult HandleDeletion(Span target, char previousChar, SourceChange change)
{
// What's left after deleting?
if (previousChar == '.')
{
return TryAcceptChange(target, change, PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional);
return TryAcceptChange(target, change, PartialParseResult.Accepted | PartialParseResult.Provisional);
}
else if (ParserHelpers.IsIdentifierPart(previousChar))
{
@ -293,11 +293,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
}
else
{
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
}
private PartialParseResultInternal HandleInsertion(Span target, char previousChar, SourceChange change)
private PartialParseResult HandleInsertion(Span target, char previousChar, SourceChange change)
{
// What are we inserting after?
if (previousChar == '.')
@ -310,11 +310,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
}
else
{
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
}
private PartialParseResultInternal HandleInsertionAfterIdPart(Span target, SourceChange change)
private PartialParseResult HandleInsertionAfterIdPart(Span target, SourceChange change)
{
// If the insertion is a full identifier part, accept it
if (ParserHelpers.IsIdentifier(change.NewText, requireIdentifierStart: false))
@ -324,16 +324,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
else if (EndsWithDot(change.NewText))
{
// Accept it, possibly provisionally
var result = PartialParseResultInternal.Accepted;
var result = PartialParseResult.Accepted;
if (!AcceptTrailingDot)
{
result |= PartialParseResultInternal.Provisional;
result |= PartialParseResult.Provisional;
}
return TryAcceptChange(target, change, result);
}
else
{
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
}
@ -344,22 +344,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
content.Take(content.Length - 1).All(ParserHelpers.IsIdentifierPart));
}
private PartialParseResultInternal HandleInsertionAfterDot(Span target, SourceChange change)
private PartialParseResult HandleInsertionAfterDot(Span target, SourceChange change)
{
// If the insertion is a full identifier or another dot, accept it
if (ParserHelpers.IsIdentifier(change.NewText) || change.NewText == ".")
{
return TryAcceptChange(target, change);
}
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
private PartialParseResultInternal TryAcceptChange(Span target, SourceChange change, PartialParseResultInternal acceptResult = PartialParseResultInternal.Accepted)
private PartialParseResult TryAcceptChange(Span target, SourceChange change, PartialParseResult acceptResult = PartialParseResult.Accepted)
{
var content = change.GetEditedContent(target);
if (StartsWithKeyword(content))
{
return PartialParseResultInternal.Rejected | PartialParseResultInternal.SpanContextChanged;
return PartialParseResult.Rejected | PartialParseResult.SpanContextChanged;
}
return acceptResult;

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
/// Provisional may NOT be set with Rejected and SpanContextChanged may NOT be set with Accepted.
/// </remarks>
[Flags]
internal enum PartialParseResultInternal
internal enum PartialParseResult
{
/// <summary>
/// Indicates that the edit could not be accepted and that a reparse is underway.

View File

@ -38,14 +38,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
public virtual EditResult ApplyChange(Span target, SourceChange change, bool force)
{
var result = PartialParseResultInternal.Accepted;
var result = PartialParseResult.Accepted;
if (!force)
{
result = CanAcceptChange(target, change);
}
// If the change is accepted then apply the change
if ((result & PartialParseResultInternal.Accepted) == PartialParseResultInternal.Accepted)
if ((result & PartialParseResult.Accepted) == PartialParseResult.Accepted)
{
return new EditResult(result, UpdateSpan(target, change));
}
@ -60,9 +60,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
(changeOldEnd < end || (changeOldEnd == end && AcceptedCharacters != AcceptedCharactersInternal.None));
}
protected virtual PartialParseResultInternal CanAcceptChange(Span target, SourceChange change)
protected virtual PartialParseResult CanAcceptChange(Span target, SourceChange change)
{
return PartialParseResultInternal.Rejected;
return PartialParseResult.Rejected;
}
protected virtual SpanBuilder UpdateSpan(Span target, SourceChange change)

View File

@ -48,11 +48,7 @@ namespace Microsoft.CodeAnalysis.Razor
for (var i = 0; i < types.Count; i++)
{
var descriptor = factory.CreateDescriptor(types[i]);
if (descriptor != null)
{
context.Results.Add(descriptor);
}
context.Results.Add(descriptor);
}
}

View File

@ -31,7 +31,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
{
var projectId = ProjectId.CreateFromSerialized(projectIdBytes, projectDebugName);
var solution = await GetSolutionAsync().ConfigureAwait(false);
var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);
var project = solution.GetProject(projectId);
var resolver = new DefaultTagHelperResolver(designTime: true);

View File

@ -1,419 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServices.Razor
{
internal class BackgroundParser : IDisposable
{
private MainThreadState _main;
private BackgroundThread _bg;
public BackgroundParser(RazorTemplateEngine templateEngine, string filePath)
{
_main = new MainThreadState(filePath);
_bg = new BackgroundThread(_main, templateEngine, filePath);
_main.ResultsReady += (sender, args) => OnResultsReady(args);
}
/// <summary>
/// Fired on the main thread.
/// </summary>
public event EventHandler<DocumentParseCompleteEventArgs> ResultsReady;
public bool IsIdle
{
get { return _main.IsIdle; }
}
public void Start()
{
_bg.Start();
}
public void Cancel()
{
_main.Cancel();
}
public void QueueChange(SourceChange change, ITextSnapshot snapshot)
{
var edit = new Edit(change, snapshot);
_main.QueueChange(edit);
}
public void Dispose()
{
_main.Cancel();
}
public IDisposable SynchronizeMainThreadState()
{
return _main.Lock();
}
protected virtual void OnResultsReady(DocumentParseCompleteEventArgs args)
{
var handler = ResultsReady;
if (handler != null)
{
handler(this, args);
}
}
private static bool TreesAreDifferent(RazorSyntaxTree leftTree, RazorSyntaxTree rightTree, IEnumerable<Edit> edits, CancellationToken cancelToken)
{
return TreesAreDifferent(leftTree.Root, rightTree.Root, edits.Select(edit => edit.Change), cancelToken);
}
internal static bool TreesAreDifferent(Block leftTree, Block rightTree, IEnumerable<SourceChange> changes, CancellationToken cancelToken)
{
// Apply all the pending changes to the original tree
// PERF: If this becomes a bottleneck, we can probably do it the other way around,
// i.e. visit the tree and find applicable changes for each node.
foreach (var change in changes)
{
cancelToken.ThrowIfCancellationRequested();
var changeOwner = leftTree.LocateOwner(change);
// Apply the change to the tree
if (changeOwner == null)
{
return true;
}
var result = changeOwner.EditHandler.ApplyChange(changeOwner, change, force: true);
changeOwner.ReplaceWith(result.EditedSpan);
}
// Now compare the trees
var treesDifferent = !leftTree.EquivalentTo(rightTree);
return treesDifferent;
}
private abstract class ThreadStateBase
{
#if DEBUG
private int _id = -1;
#endif
protected ThreadStateBase()
{
}
[Conditional("DEBUG")]
protected void SetThreadId(int id)
{
#if DEBUG
_id = id;
#endif
}
[Conditional("DEBUG")]
protected void EnsureOnThread()
{
#if DEBUG
Debug.Assert(_id != -1, "SetThreadId was never called!");
Debug.Assert(Thread.CurrentThread.ManagedThreadId == _id, "Called from an unexpected thread!");
#endif
}
[Conditional("DEBUG")]
protected void EnsureNotOnThread()
{
#if DEBUG
Debug.Assert(_id != -1, "SetThreadId was never called!");
Debug.Assert(Thread.CurrentThread.ManagedThreadId != _id, "Called from an unexpected thread!");
#endif
}
}
private class MainThreadState : ThreadStateBase, IDisposable
{
private readonly CancellationTokenSource _cancelSource = new CancellationTokenSource();
private readonly ManualResetEventSlim _hasParcel = new ManualResetEventSlim(false);
private CancellationTokenSource _currentParcelCancelSource;
private string _fileName;
private readonly object _stateLock = new object();
private IList<Edit> _changes = new List<Edit>();
public MainThreadState(string fileName)
{
_fileName = fileName;
SetThreadId(Thread.CurrentThread.ManagedThreadId);
}
public event EventHandler<DocumentParseCompleteEventArgs> ResultsReady;
public CancellationToken CancelToken
{
get { return _cancelSource.Token; }
}
public bool IsIdle
{
get
{
lock (_stateLock)
{
return _currentParcelCancelSource == null;
}
}
}
public void Cancel()
{
EnsureOnThread();
_cancelSource.Cancel();
}
public IDisposable Lock()
{
Monitor.Enter(_stateLock);
return new DisposableAction(() => Monitor.Exit(_stateLock));
}
public void QueueChange(Edit edit)
{
EnsureOnThread();
lock (_stateLock)
{
// CurrentParcel token source is not null ==> There's a parse underway
if (_currentParcelCancelSource != null)
{
_currentParcelCancelSource.Cancel();
}
_changes.Add(edit);
_hasParcel.Set();
}
}
public WorkParcel GetParcel()
{
EnsureNotOnThread(); // Only the background thread can get a parcel
_hasParcel.Wait(_cancelSource.Token);
_hasParcel.Reset();
lock (_stateLock)
{
// Create a cancellation source for this parcel
_currentParcelCancelSource = new CancellationTokenSource();
var changes = _changes;
_changes = new List<Edit>();
return new WorkParcel(changes, _currentParcelCancelSource.Token);
}
}
public void ReturnParcel(DocumentParseCompleteEventArgs args)
{
lock (_stateLock)
{
// Clear the current parcel cancellation source
if (_currentParcelCancelSource != null)
{
_currentParcelCancelSource.Dispose();
_currentParcelCancelSource = null;
}
// If there are things waiting to be parsed, just don't fire the event because we're already out of date
if (_changes.Any())
{
return;
}
}
var handler = ResultsReady;
if (handler != null)
{
handler(this, args);
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
if (_currentParcelCancelSource != null)
{
_currentParcelCancelSource.Dispose();
_currentParcelCancelSource = null;
}
_cancelSource.Dispose();
_hasParcel.Dispose();
}
}
}
private class BackgroundThread : ThreadStateBase
{
private MainThreadState _main;
private Thread _backgroundThread;
private CancellationToken _shutdownToken;
private RazorTemplateEngine _templateEngine;
private string _filePath;
private RazorSyntaxTree _currentSyntaxTree;
private IList<Edit> _previouslyDiscarded = new List<Edit>();
public BackgroundThread(MainThreadState main, RazorTemplateEngine templateEngine, string fileName)
{
// Run on MAIN thread!
_main = main;
_shutdownToken = _main.CancelToken;
_templateEngine = templateEngine;
_filePath = fileName;
_backgroundThread = new Thread(WorkerLoop);
SetThreadId(_backgroundThread.ManagedThreadId);
}
// **** ANY THREAD ****
public void Start()
{
_backgroundThread.Start();
}
// **** BACKGROUND THREAD ****
private void WorkerLoop()
{
var fileNameOnly = Path.GetFileName(_filePath);
try
{
EnsureOnThread();
while (!_shutdownToken.IsCancellationRequested)
{
// Grab the parcel of work to do
var parcel = _main.GetParcel();
if (parcel.Edits.Any())
{
try
{
DocumentParseCompleteEventArgs args = null;
using (var linkedCancel = CancellationTokenSource.CreateLinkedTokenSource(_shutdownToken, parcel.CancelToken))
{
if (!linkedCancel.IsCancellationRequested)
{
// Collect ALL changes
List<Edit> allEdits;
if (_previouslyDiscarded != null)
{
allEdits = Enumerable.Concat(_previouslyDiscarded, parcel.Edits).ToList();
}
else
{
allEdits = parcel.Edits.ToList();
}
var finalEdit = allEdits.Last();
var results = ParseChange(finalEdit.Snapshot, linkedCancel.Token);
if (results != null && !linkedCancel.IsCancellationRequested)
{
// Clear discarded changes list
_previouslyDiscarded = null;
var treeStructureChanged = _currentSyntaxTree == null || TreesAreDifferent(_currentSyntaxTree, results.GetSyntaxTree(), allEdits, parcel.CancelToken);
_currentSyntaxTree = results.GetSyntaxTree();
// Build Arguments
args = new DocumentParseCompleteEventArgs(
finalEdit.Change,
finalEdit.Snapshot,
treeStructureChanged,
results);
}
else
{
// Parse completed but we were cancelled in the mean time. Add these to the discarded changes set
_previouslyDiscarded = allEdits;
}
}
}
if (args != null)
{
_main.ReturnParcel(args);
}
}
catch (OperationCanceledException)
{
}
}
else
{
Thread.Yield();
}
}
}
catch (OperationCanceledException)
{
// Do nothing. Just shut down.
}
finally
{
// Clean up main thread resources
_main.Dispose();
}
}
private RazorCodeDocument ParseChange(ITextSnapshot snapshot, CancellationToken token)
{
EnsureOnThread();
var sourceDocument = new TextSnapshotSourceDocument(snapshot, _filePath);
var imports = _templateEngine.GetImports(_filePath);
var codeDocument = RazorCodeDocument.Create(sourceDocument, imports);
_templateEngine.GenerateCode(codeDocument);
return codeDocument;
}
}
private class WorkParcel
{
public WorkParcel(IList<Edit> changes, CancellationToken cancelToken)
{
Edits = changes;
CancelToken = cancelToken;
}
public CancellationToken CancelToken { get; }
public IList<Edit> Edits { get; }
}
private class Edit
{
public Edit(SourceChange change, ITextSnapshot snapshot)
{
Change = change;
Snapshot = snapshot;
}
public SourceChange Change { get; }
public ITextSnapshot Snapshot { get; set; }
}
}
}

View File

@ -23,7 +23,11 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
using (var session = await client.CreateSessionAsync(project.Solution))
{
var directives = await session.InvokeAsync<IEnumerable<DirectiveDescriptor>>("GetDirectivesAsync", new object[] { project.Id.Id, "Foo", }).ConfigureAwait(false);
var directives = await session.InvokeAsync<IEnumerable<DirectiveDescriptor>>(
"GetDirectivesAsync",
new object[] { project.Id.Id, "Foo", },
cancellationToken)
.ConfigureAwait(false);
return directives;
}
}
@ -37,4 +41,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
}
}
}
#endif
#endif

View File

@ -21,7 +21,11 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
using (var session = await client.CreateSessionAsync(project.Solution))
{
var document = await session.InvokeAsync<RazorEngineDocument>("GenerateDocumentAsync", new object[] { project.Id.Id, "Foo", filePath, text }).ConfigureAwait(false);
var document = await session.InvokeAsync<RazorEngineDocument>(
"GenerateDocumentAsync",
new object[] { project.Id.Id, "Foo", filePath, text },
cancellationToken)
.ConfigureAwait(false);
return document;
}
}

View File

@ -44,8 +44,10 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
if (session != null)
{
var jsonObject = await session.InvokeAsync<JObject>(
"GetTagHelpersAsync",
new object[] { project.Id.Id, "Foo", }).ConfigureAwait(false);
"GetTagHelpersAsync",
new object[] { project.Id.Id, "Foo", },
CancellationToken.None
).ConfigureAwait(false);
result = GetTagHelperResolutionResult(jsonObject);

View File

@ -1,47 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServices.Razor
{
/// <summary>
/// Arguments for the <see cref="RazorEditorParser.DocumentParseComplete"/> event in <see cref="RazorEditorParser"/>.
/// </summary>
public sealed class DocumentParseCompleteEventArgs : EventArgs
{
public DocumentParseCompleteEventArgs(
SourceChange change,
ITextSnapshot buffer,
bool treeStructureChanged,
RazorCodeDocument codeDocument)
{
SourceChange = change;
Buffer = buffer;
TreeStructureChanged = treeStructureChanged;
CodeDocument = codeDocument;
}
/// <summary>
/// The <see cref="AspNetCore.Razor.Language.SourceChange"/> which triggered the re-parse.
/// </summary>
public SourceChange SourceChange { get; }
/// <summary>
/// The text snapshot used in the re-parse.
/// </summary>
public ITextSnapshot Buffer { get; }
/// <summary>
/// Indicates if the tree structure has actually changed since the previous re-parse.
/// </summary>
public bool TreeStructureChanged { get; }
/// <summary>
/// The result of the parsing and code generation.
/// </summary>
public RazorCodeDocument CodeDocument { get; }
}
}

View File

@ -1,21 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.VisualStudio.LanguageServices.Razor
{
[Flags]
public enum PartialParseResult
{
Rejected = 1,
Accepted = 2,
Provisional = 4,
SpanContextChanged = 8,
AutoCompleteBlock = 16
}
}

View File

@ -1,190 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Legacy;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServices.Razor
{
public class RazorEditorParser : IDisposable
{
private AspNetCore.Razor.Language.Legacy.Span _lastChangeOwner;
private AspNetCore.Razor.Language.Legacy.Span _lastAutoCompleteSpan;
private BackgroundParser _parser;
public RazorEditorParser(RazorTemplateEngine templateEngine, string filePath)
{
if (templateEngine == null)
{
throw new ArgumentNullException(nameof(templateEngine));
}
if (string.IsNullOrEmpty(filePath))
{
throw new ArgumentException(
AspNetCore.Razor.Language.Resources.ArgumentCannotBeNullOrEmpty,
nameof(filePath));
}
TemplateEngine = templateEngine;
FilePath = filePath;
_parser = new BackgroundParser(templateEngine, filePath);
_parser.ResultsReady += (sender, args) => OnDocumentParseComplete(args);
_parser.Start();
}
/// <summary>
/// Event fired when a full reparse of the document completes.
/// </summary>
public event EventHandler<DocumentParseCompleteEventArgs> DocumentParseComplete;
public RazorTemplateEngine TemplateEngine { get; }
public string FilePath { get; }
// Internal for testing.
internal RazorSyntaxTree CurrentSyntaxTree { get; private set; }
// Internal for testing.
internal bool LastResultProvisional { get; private set; }
public virtual string GetAutoCompleteString()
{
if (_lastAutoCompleteSpan?.EditHandler is AutoCompleteEditHandler editHandler)
{
return editHandler.AutoCompleteString;
}
return null;
}
public virtual PartialParseResult CheckForStructureChanges(SourceChange change, ITextSnapshot snapshot)
{
if (snapshot == null)
{
throw new ArgumentNullException(nameof(snapshot));
}
var result = PartialParseResultInternal.Rejected;
using (_parser.SynchronizeMainThreadState())
{
// Check if we can partial-parse
if (CurrentSyntaxTree != null && _parser.IsIdle)
{
result = TryPartialParse(change);
}
}
// If partial parsing failed or there were outstanding parser tasks, start a full reparse
if ((result & PartialParseResultInternal.Rejected) == PartialParseResultInternal.Rejected)
{
_parser.QueueChange(change, snapshot);
}
// Otherwise, remember if this was provisionally accepted for next partial parse
LastResultProvisional = (result & PartialParseResultInternal.Provisional) == PartialParseResultInternal.Provisional;
VerifyFlagsAreValid(result);
return (PartialParseResult)result;
}
/// <summary>
/// Disposes of this parser. Should be called when the editor window is closed and the document is unloaded.
/// </summary>
public void Dispose()
{
_parser.Dispose();
GC.SuppressFinalize(this);
}
private PartialParseResultInternal TryPartialParse(SourceChange change)
{
var result = PartialParseResultInternal.Rejected;
// Try the last change owner
if (_lastChangeOwner != null && _lastChangeOwner.EditHandler.OwnsChange(_lastChangeOwner, change))
{
var editResult = _lastChangeOwner.EditHandler.ApplyChange(_lastChangeOwner, change);
result = editResult.Result;
if ((editResult.Result & PartialParseResultInternal.Rejected) != PartialParseResultInternal.Rejected)
{
_lastChangeOwner.ReplaceWith(editResult.EditedSpan);
}
return result;
}
// Locate the span responsible for this change
_lastChangeOwner = CurrentSyntaxTree.Root.LocateOwner(change);
if (LastResultProvisional)
{
// Last change owner couldn't accept this, so we must do a full reparse
result = PartialParseResultInternal.Rejected;
}
else if (_lastChangeOwner != null)
{
var editResult = _lastChangeOwner.EditHandler.ApplyChange(_lastChangeOwner, change);
result = editResult.Result;
if ((editResult.Result & PartialParseResultInternal.Rejected) != PartialParseResultInternal.Rejected)
{
_lastChangeOwner.ReplaceWith(editResult.EditedSpan);
}
if ((result & PartialParseResultInternal.AutoCompleteBlock) == PartialParseResultInternal.AutoCompleteBlock)
{
_lastAutoCompleteSpan = _lastChangeOwner;
}
else
{
_lastAutoCompleteSpan = null;
}
}
return result;
}
private void OnDocumentParseComplete(DocumentParseCompleteEventArgs args)
{
using (_parser.SynchronizeMainThreadState())
{
CurrentSyntaxTree = args.CodeDocument.GetSyntaxTree();
_lastChangeOwner = null;
}
Debug.Assert(args != null, "Event arguments cannot be null");
EventHandler<DocumentParseCompleteEventArgs> handler = DocumentParseComplete;
if (handler != null)
{
try
{
handler(this, args);
}
catch (Exception ex)
{
Debug.WriteLine("[RzEd] Document Parse Complete Handler Threw: " + ex.ToString());
}
}
}
[Conditional("DEBUG")]
private static void VerifyFlagsAreValid(PartialParseResultInternal result)
{
Debug.Assert(((result & PartialParseResultInternal.Accepted) == PartialParseResultInternal.Accepted) ||
((result & PartialParseResultInternal.Rejected) == PartialParseResultInternal.Rejected),
"Partial Parse result does not have either of Accepted or Rejected flags set");
Debug.Assert(((result & PartialParseResultInternal.Rejected) == PartialParseResultInternal.Rejected) ||
((result & PartialParseResultInternal.SpanContextChanged) != PartialParseResultInternal.SpanContextChanged),
"Partial Parse result was Accepted AND had SpanContextChanged flag set");
Debug.Assert(((result & PartialParseResultInternal.Rejected) == PartialParseResultInternal.Rejected) ||
((result & PartialParseResultInternal.AutoCompleteBlock) != PartialParseResultInternal.AutoCompleteBlock),
"Partial Parse result was Accepted AND had AutoCompleteBlock flag set");
Debug.Assert(((result & PartialParseResultInternal.Accepted) == PartialParseResultInternal.Accepted) ||
((result & PartialParseResultInternal.Provisional) != PartialParseResultInternal.Provisional),
"Partial Parse result was Rejected AND had Provisional flag set");
}
}
}

View File

@ -1,79 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Text;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServices.Razor
{
internal class TextSnapshotSourceDocument : RazorSourceDocument
{
private readonly ITextSnapshot _buffer;
private readonly RazorSourceLineCollection _lines;
public TextSnapshotSourceDocument(ITextSnapshot snapshot, string filePath)
{
if (snapshot == null)
{
throw new ArgumentNullException(nameof(snapshot));
}
if (filePath == null)
{
throw new ArgumentNullException(nameof(filePath));
}
_buffer = snapshot;
FilePath = filePath;
_lines = new DefaultRazorSourceLineCollection(this);
}
public override char this[int position] => _buffer[position];
public override Encoding Encoding => Encoding.UTF8;
public override int Length => _buffer.Length;
public override RazorSourceLineCollection Lines => _lines;
public override string FilePath { get; }
public override void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
{
if (destination == null)
{
throw new ArgumentNullException(nameof(destination));
}
if (sourceIndex < 0)
{
throw new ArgumentOutOfRangeException(nameof(sourceIndex));
}
if (destinationIndex < 0)
{
throw new ArgumentOutOfRangeException(nameof(destinationIndex));
}
if (count < 0 || count > Length - sourceIndex || count > destination.Length - destinationIndex)
{
throw new ArgumentOutOfRangeException(nameof(count));
}
if (count == 0)
{
return;
}
for (var i = 0; i < count; i++)
{
destination[destinationIndex + i] = this[sourceIndex + i];
}
}
public override byte[] GetChecksum() => throw new NotImplementedException();
}
}

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,34 +1,34 @@
Source Location: (13:0,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|this.ToString()|
Generated Location: (1037:26,13 [15] )
Generated Location: (1215:27,13 [15] )
|this.ToString()|
Source Location: (54:2,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|string.Format("{0}", "Hello")|
Generated Location: (1173:31,6 [29] )
Generated Location: (1351:32,6 [29] )
|string.Format("{0}", "Hello")|
Source Location: (95:4,2 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|
var cls = "foo";
|
Generated Location: (1319:36,2 [25] )
Generated Location: (1497:37,2 [25] )
|
var cls = "foo";
|
Source Location: (134:7,11 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|if(cls != null) { |
Generated Location: (1467:42,11 [18] )
Generated Location: (1645:43,11 [18] )
|if(cls != null) { |
Source Location: (153:7,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|cls|
Generated Location: (1629:47,30 [3] )
Generated Location: (1807:48,30 [3] )
|cls|
Source Location: (156:7,33 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
| }|
Generated Location: (1780:52,33 [2] )
Generated Location: (1958:53,33 [2] )
| }|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml), null)]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml), null)]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,5 +1,5 @@
Source Location: (159:11,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml)
|MyService<TModel>|
Generated Location: (678:18,0 [17] )
Generated Location: (885:19,0 [17] )
|MyService<TModel>|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,10 +1,10 @@
Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml)
|MyBasePageForViews<TModel>|
Generated Location: (654:18,0 [26] )
Generated Location: (844:19,0 [26] )
|MyBasePageForViews<TModel>|
Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml)
|MyModel|
Generated Location: (794:22,0 [7] )
Generated Location: (984:23,0 [7] )
|MyModel|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml), null)]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml), null)]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,5 +1,5 @@
Source Location: (14:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml)
|MyModel|
Generated Location: (653:18,0 [7] )
Generated Location: (863:19,0 [7] )
|MyModel|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,25 +1,25 @@
Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|MyModel|
Generated Location: (682:18,0 [7] )
Generated Location: (870:19,0 [7] )
|MyModel|
Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|MyApp|
Generated Location: (784:22,0 [5] )
Generated Location: (972:23,0 [5] )
|MyApp|
Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|MyPropertyName|
Generated Location: (904:26,22 [14] )
Generated Location: (1092:27,22 [14] )
|MyPropertyName|
Source Location: (54:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|MyService<TModel>|
Generated Location: (988:30,0 [17] )
Generated Location: (1176:31,0 [17] )
|MyService<TModel>|
Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|Html|
Generated Location: (1132:34,22 [4] )
Generated Location: (1320:35,22 [4] )
|Html|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,45 +1,45 @@
Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|MyModel|
Generated Location: (686:18,0 [7] )
Generated Location: (878:19,0 [7] )
|MyModel|
Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|MyApp|
Generated Location: (788:22,0 [5] )
Generated Location: (980:23,0 [5] )
|MyApp|
Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|MyPropertyName|
Generated Location: (908:26,22 [14] )
Generated Location: (1100:27,22 [14] )
|MyPropertyName|
Source Location: (58:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|MyService<TModel>|
Generated Location: (992:30,0 [17] )
Generated Location: (1184:31,0 [17] )
|MyService<TModel>|
Source Location: (76:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|Html|
Generated Location: (1136:34,22 [4] )
Generated Location: (1328:35,22 [4] )
|Html|
Source Location: (93:3,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|MyApp|
Generated Location: (1210:38,0 [5] )
Generated Location: (1402:39,0 [5] )
|MyApp|
Source Location: (99:3,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|MyPropertyName2|
Generated Location: (1330:42,22 [15] )
Generated Location: (1522:43,22 [15] )
|MyPropertyName2|
Source Location: (129:4,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|MyService<TModel>|
Generated Location: (1415:46,0 [17] )
Generated Location: (1607:47,0 [17] )
|MyService<TModel>|
Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|Html2|
Generated Location: (1559:50,22 [5] )
Generated Location: (1751:51,22 [5] )
|Html2|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,10 +1,10 @@
Source Location: (8:0,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml)
|MyApp|
Generated Location: (673:18,0 [5] )
Generated Location: (852:19,0 [5] )
|MyApp|
Source Location: (14:0,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml)
|MyPropertyName|
Generated Location: (793:22,22 [14] )
Generated Location: (972:23,22 [14] )
|MyPropertyName|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml), null)]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MalformedPageDirective_cshtml), null)]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,20 +1,20 @@
Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|DateTime|
Generated Location: (758:19,0 [8] )
Generated Location: (955:20,0 [8] )
|DateTime|
Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|"InputTestTagHelper, AppCode"|
Generated Location: (899:23,37 [29] )
Generated Location: (1096:24,37 [29] )
|"InputTestTagHelper, AppCode"|
Source Location: (83:4,17 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|Date|
Generated Location: (1547:36,102 [4] )
Generated Location: (1744:37,102 [4] )
|Date|
Source Location: (111:5,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|Model|
Generated Location: (1863:42,94 [5] )
Generated Location: (2060:43,94 [5] )
|Model|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Model_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,5 +1,5 @@
Source Location: (7:0,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Model.cshtml)
|System.Collections.IEnumerable|
Generated Location: (695:18,0 [30] )
Generated Location: (873:19,0 [30] )
|System.Collections.IEnumerable|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_MultipleModels_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,10 +1,10 @@
Source Location: (7:0,7 [21] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml)
|ThisShouldBeGenerated|
Generated Location: (695:18,0 [21] )
Generated Location: (882:19,0 [21] )
|ThisShouldBeGenerated|
Source Location: (37:1,7 [30] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/MultipleModels.cshtml)
|System.Collections.IEnumerable|
Generated Location: (825:22,0 [30] )
Generated Location: (1012:23,0 [30] )
|System.Collections.IEnumerable|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.PageWithNamespace_Page), null)]
namespace Test.Namespace
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(Test.Namespace.PageWithNamespace_Page), null)]
NamespaceDeclaration - - Test.Namespace
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,5 +1,5 @@
Source Location: (18:1,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/PageWithNamespace.cshtml)
|Test.Namespace|
Generated Location: (664:18,44 [14] )
Generated Location: (813:19,44 [14] )
|Test.Namespace|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml), null)]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPagesWithoutModel_cshtml), null)]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,16 +1,16 @@
Source Location: (38:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml)
|using Microsoft.AspNetCore.Mvc.RazorPages|
Generated Location: (487:14,0 [41] )
Generated Location: (696:15,0 [41] )
|using Microsoft.AspNetCore.Mvc.RazorPages|
Source Location: (23:2,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml)
|"*, AppCode"|
Generated Location: (944:24,37 [12] )
Generated Location: (1153:25,37 [12] )
|"*, AppCode"|
Source Location: (566:24,47 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml)
|Name|
Generated Location: (1507:37,47 [4] )
Generated Location: (1716:38,47 [4] )
|Name|
Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithoutModel.cshtml)
@ -28,7 +28,7 @@ Source Location: (95:5,12 [283] TestFiles/IntegrationTests/CodeGenerationIntegra
public string Name { get; set; }
}
|
Generated Location: (1988:48,12 [283] )
Generated Location: (2197:49,12 [283] )
|
public IActionResult OnPost(Customer customer)
{

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml), null)]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.RazorPageAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_RazorPages_cshtml), null)]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,21 +1,21 @@
Source Location: (55:4,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml)
|using Microsoft.AspNetCore.Mvc.RazorPages|
Generated Location: (475:14,0 [41] )
Generated Location: (672:15,0 [41] )
|using Microsoft.AspNetCore.Mvc.RazorPages|
Source Location: (16:2,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml)
|NewModel|
Generated Location: (883:24,0 [8] )
Generated Location: (1080:25,0 [8] )
|NewModel|
Source Location: (40:3,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml)
|"*, AppCode"|
Generated Location: (1024:28,37 [12] )
Generated Location: (1221:29,37 [12] )
|"*, AppCode"|
Source Location: (661:28,47 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml)
|Model.Name|
Generated Location: (1575:41,47 [10] )
Generated Location: (1772:42,47 [10] )
|Model.Name|
Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPages.cshtml)
@ -36,7 +36,7 @@ Source Location: (112:6,12 [360] TestFiles/IntegrationTests/CodeGenerationIntegr
public string Name { get; set; }
}
|
Generated Location: (2050:52,12 [360] )
Generated Location: (2247:53,12 [360] )
|
public class NewModel : PageModel
{

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ViewComponentTagHelper_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,19 +1,19 @@
Source Location: (14:0,14 [12] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml)
|"*, AppCode"|
Generated Location: (973:20,37 [12] )
Generated Location: (1168:21,37 [12] )
|"*, AppCode"|
Source Location: (30:1,2 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml)
|
var foo = "Hello";
|
Generated Location: (1419:32,2 [26] )
Generated Location: (1614:33,2 [26] )
|
var foo = "Hello";
|
Source Location: (83:5,22 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewComponentTagHelper.cshtml)
|foo|
Generated Location: (1877:40,22 [3] )
Generated Location: (2072:41,22 [3] )
|foo|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.ViewWithNamespace_View))]
namespace Test.Namespace
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(Test.Namespace.ViewWithNamespace_View))]
NamespaceDeclaration - - Test.Namespace
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,5 +1,5 @@
Source Location: (11:0,11 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ViewWithNamespace.cshtml)
|Test.Namespace|
Generated Location: (673:18,44 [14] )
Generated Location: (808:19,44 [14] )
|Test.Namespace|

View File

@ -1,5 +1,6 @@
// <auto-generated/>
#pragma warning disable 1591
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml))]
namespace AspNetCore
{
#line hidden

View File

@ -1,4 +1,6 @@
Document -
CSharpCode -
IntermediateToken - - CSharp - [assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(null, typeof(AspNetCore.TestFiles_IntegrationTests_CodeGenerationIntegrationTest__ViewImports_cshtml))]
NamespaceDeclaration - - AspNetCore
UsingDirective - - TModel = global::System.Object
UsingDirective - (1:0,1 [12] ) - System

View File

@ -1,10 +1,10 @@
Source Location: (8:0,8 [19] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml)
|IHtmlHelper<TModel>|
Generated Location: (679:18,0 [19] )
Generated Location: (864:19,0 [19] )
|IHtmlHelper<TModel>|
Source Location: (28:0,28 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/_ViewImports.cshtml)
|Model|
Generated Location: (827:22,22 [5] )
Generated Location: (1012:23,22 [5] )
|Model|

View File

@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test
var result = directiveTokenHandler.CanAcceptChange(target, sourceChange);
// Assert
Assert.Equal(PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional, result);
Assert.Equal(PartialParseResult.Accepted | PartialParseResult.Provisional, result);
}
[Theory]
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test
var result = directiveTokenHandler.CanAcceptChange(target, sourceChange);
// Assert
Assert.Equal(PartialParseResultInternal.Rejected, result);
Assert.Equal(PartialParseResult.Rejected, result);
}
private class TestDirectiveTokenEditHandler : DirectiveTokenEditHandler
@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Test
{
}
public new PartialParseResultInternal CanAcceptChange(Span target, SourceChange change)
public new PartialParseResult CanAcceptChange(Span target, SourceChange change)
=> base.CanAcceptChange(target, change);
}
}

View File

@ -0,0 +1,53 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.AspNetCore.Razor.Language.Legacy
{
public class StringTextBuffer : ITextBuffer, IDisposable
{
private string _buffer;
public bool Disposed { get; set; }
public StringTextBuffer(string buffer)
{
_buffer = buffer;
}
public int Length
{
get { return _buffer.Length; }
}
public int Position { get; set; }
public int Read()
{
if (Position >= _buffer.Length)
{
return -1;
}
return _buffer[Position++];
}
public int Peek()
{
if (Position >= _buffer.Length)
{
return -1;
}
return _buffer[Position];
}
public void Dispose()
{
Disposed = true;
}
public object VersionToken
{
get { return _buffer; }
}
}
}

View File

@ -0,0 +1,16 @@
@{
string hello = "Hello, World";
}
<html>
<head>
<title>Simple Page</title>
</head>
<body>
<h1>Simple Page</h1>
<p>@hello</p>
<p>
@foreach(char c in hello) {@c}
</p>
</body>
</html>

View File

@ -0,0 +1,43 @@
namespace Razor
{
#line hidden
public class Template
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
private static System.Object __o = null;
#pragma warning disable 1998
public async override global::System.Threading.Tasks.Task ExecuteAsync()
{
#line 1 "C:\This\Path\Is\Just\For\Line\Pragmas.cshtml"
string hello = "Hello, World";
#line default
#line hidden
#line 11 "C:\This\Path\Is\Just\For\Line\Pragmas.cshtml"
__o = hello;
#line default
#line hidden
#line 13 "C:\This\Path\Is\Just\For\Line\Pragmas.cshtml"
foreach(char c in hello) {
#line default
#line hidden
#line 13 "C:\This\Path\Is\Just\For\Line\Pragmas.cshtml"
__o = c;
#line default
#line hidden
#line 13 "C:\This\Path\Is\Just\For\Line\Pragmas.cshtml"
}
#line default
#line hidden
}
#pragma warning restore 1998
}
}

View File

@ -6,6 +6,7 @@
<DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>

View File

@ -1,38 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Xunit;
namespace Microsoft.CodeAnalysis.Razor
{
public class DefaultTagHelperDescriptorProviderTest
{
private static readonly Assembly _assembly = typeof(DefaultTagHelperDescriptorProviderTest).GetTypeInfo().Assembly;
[Fact]
public void Execute_DoesNotAddEditorBrowsableNeverDescriptorsAtDesignTime()
{
// Arrange
var editorBrowsableTypeName = "Microsoft.CodeAnalysis.Razor.Workspaces.Test.EditorBrowsableTagHelper";
var compilation = TestCompilation.Create(_assembly);
var descriptorProvider = new DefaultTagHelperDescriptorProvider()
{
DesignTime = true,
};
var context = TagHelperDescriptorProviderContext.Create();
// Act
descriptorProvider.Execute(context);
// Assert
Assert.NotNull(compilation.GetTypeByMetadataName(editorBrowsableTypeName));
var nullDescriptors = context.Results.Where(descriptor => descriptor == null);
Assert.Empty(nullDescriptors);
var editorBrowsableDescriptor = context.Results.Where(descriptor => descriptor.GetTypeName() == editorBrowsableTypeName);
Assert.Empty(editorBrowsableDescriptor);
}
}
}

View File

@ -2,9 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.VisualStudio.LanguageServices.Razor
namespace Microsoft.AspNetCore.Razor.Language
{
public static class TestBoundAttributeDescriptorBuilderExtensions
{

View File

@ -2,9 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.VisualStudio.LanguageServices.Razor
namespace Microsoft.AspNetCore.Razor.Language
{
public static class TestRequiredAttributeDescriptorBuilderExtensions
{

View File

@ -2,9 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.VisualStudio.LanguageServices.Razor
namespace Microsoft.AspNetCore.Razor.Language
{
public static class TestTagHelperDescriptorBuilderExtensions
{

View File

@ -2,9 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.VisualStudio.LanguageServices.Razor
namespace Microsoft.AspNetCore.Razor.Language
{
public static class TestTagMatchingRuleDescriptorBuilderExtensions
{

View File

@ -20,7 +20,6 @@
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Language\Microsoft.AspNetCore.Razor.Language.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -1,106 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.AspNetCore.Razor.Language.Legacy
{
public class StringTextSnapshot : ITextSnapshot
{
private readonly string _content;
public StringTextSnapshot(string content)
{
_content = content;
}
public char this[int position] => _content[position];
public VisualStudio.Text.ITextBuffer TextBuffer => throw new NotImplementedException();
public IContentType ContentType => throw new NotImplementedException();
public ITextVersion Version => throw new NotImplementedException();
public int Length => _content.Length;
public int LineCount => throw new NotImplementedException();
public IEnumerable<ITextSnapshotLine> Lines => throw new NotImplementedException();
public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
{
_content.CopyTo(sourceIndex, destination, destinationIndex, count);
}
public ITrackingPoint CreateTrackingPoint(int position, PointTrackingMode trackingMode)
{
throw new NotImplementedException();
}
public ITrackingPoint CreateTrackingPoint(int position, PointTrackingMode trackingMode, TrackingFidelityMode trackingFidelity)
{
throw new NotImplementedException();
}
public ITrackingSpan CreateTrackingSpan(VisualStudio.Text.Span span, SpanTrackingMode trackingMode)
{
throw new NotImplementedException();
}
public ITrackingSpan CreateTrackingSpan(VisualStudio.Text.Span span, SpanTrackingMode trackingMode, TrackingFidelityMode trackingFidelity)
{
throw new NotImplementedException();
}
public ITrackingSpan CreateTrackingSpan(int start, int length, SpanTrackingMode trackingMode)
{
throw new NotImplementedException();
}
public ITrackingSpan CreateTrackingSpan(int start, int length, SpanTrackingMode trackingMode, TrackingFidelityMode trackingFidelity)
{
throw new NotImplementedException();
}
public ITextSnapshotLine GetLineFromLineNumber(int lineNumber)
{
throw new NotImplementedException();
}
public ITextSnapshotLine GetLineFromPosition(int position)
{
throw new NotImplementedException();
}
public int GetLineNumberFromPosition(int position)
{
throw new NotImplementedException();
}
public string GetText(VisualStudio.Text.Span span)
{
throw new NotImplementedException();
}
public string GetText(int startIndex, int length) => _content.Substring(startIndex, length);
public string GetText() => _content;
public char[] ToCharArray(int startIndex, int length) => _content.ToCharArray();
public void Write(TextWriter writer, VisualStudio.Text.Span span)
{
throw new NotImplementedException();
}
public void Write(TextWriter writer)
{
throw new NotImplementedException();
}
}
}