"browser not found by alias 'C" exception when deriving from AspHighlightingTestBase

In a plugin test project I have a few CSharpHighlightingTestBase tests, which work great. Now I wanted to add tests for ASPX and Razor files and therefore used AspHighlightingTestBase.

But there, the call to this.DoTestSolution ("AspxSample.aspx") throws

JetBrains.Util.Assertion.AssertionException occurred
  Message=browser not found by alias 'C'
  StackTrace:
       at JetBrains.ReSharper.Psi.Css.BrowserCompatibility.BrowserInfo.Parse(String aliasWithVersion, ICssDefinitionsStorage storage)
       at JetBrains.ReSharper.Psi.Css.BrowserCompatibility.BrowserCompatibility.Parse(String text, ICssDefinitionsStorage storage)
       at JetBrains.ReSharper.Daemon.Css.Stages.CssValueValidatorProcess..ctor(IDaemonProcess process, CssLanguageVersion version, ISolution solution, ResolveHighlighterRegistrar resolveHighlighterRegistrar, IContextBoundSettingsStore settingsStore, ICssFile file, ISettingsOptimization settingsOptimization, ICssDefinitionsStorage storage)
       at JetBrains.ReSharper.Daemon.Css.Stages.CssValueValidatorStage.CreateProcess(IDaemonProcess process, IContextBoundSettingsStore settings, DaemonProcessKind processKind, ICssFile file)
       at JetBrains.ReSharper.Daemon.Css.Impl.CssDaemonStageBase.<>c__DisplayClass1.<CreateProcess>b__0(IFile file)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at JetBrains.ReSharper.Daemon.Impl.DaemonProcessBase.<>c__DisplayClass12.<DoHighlighting>b__4(IDaemonStage stage)
       at JetBrains.Application.Threading.Tasks.TaskBarrier.<>c__DisplayClass7.<>c__DisplayClass9.<EnqueueDependentJobs>b__5()
       at JetBrains.Application.Threading.Tasks.TaskHost.<>c__DisplayClass11.<Create>b__e(Object state)

... followed by ...

System.InvalidOperationException occurred
  Message=:not() should have single argument
  StackTrace:
       at System.Linq.EnumerableExJet.SingleImpl[TSource](IEnumerable`1 source, Func`2 predicate, String sExceptionMessageEmpty, String sExceptionMessageAmbiguous)
       at System.Linq.EnumerableExJet.Single[TSource](IEnumerable`1 source, String sExceptionMessageEmpty, String sExceptionMessageAmbiguous)
       at JetBrains.ReSharper.Psi.Services.Css.StructuralSearch.CssSelectorMatcherBuilder.Visitor.VisitPseudoFunctionSelector(IPseudoFunctionSelector pseudoFunctionSelectorParam, Object context)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at JetBrains.ReSharper.Psi.Services.Css.StructuralSearch.CssSelectorMatcherBuilder.Visitor.VisitSimpleSelector(ISimpleSelector simpleSelectorParam, Object context)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at JetBrains.ReSharper.Psi.Services.Css.StructuralSearch.CssSelectorMatcherBuilder.Visitor.VisitRulesetDeclarationList(IRulesetDeclarationList rulesetDeclarationListParam, Object context)
       at JetBrains.ReSharper.Psi.Services.Css.StructuralSearch.CssStructuralSearchPatternBuilder.CreateMatcher(String pattern, IDictionary`2 placeholders, StructuralSearchPatternParams params)
       at JetBrains.ReSharper.Psi.Services.Html.StructuralSearch.Placeholders.HtmlContentSequencePlaceholderMatcher..ctor(HtmlContentSequencePlaceholder placeholder, StructuralSearchPatternParams params)
       at JetBrains.ReSharper.Psi.Services.Html.StructuralSearch.Placeholders.HtmlContentSequencePlaceholder.CreateMatcher(StructuralSearchPatternParams params)
       at JetBrains.ReSharper.Psi.Services.StructuralSearch.PatternLexer.ReplacePlaceholders(String pattern, IDictionary`2 placeholders, StructuralSearchPatternParams params, Boolean createUnknownPlaceholders, Boolean deleteUnusedPlaceholders, Int32 realShift)
       at JetBrains.ReSharper.Psi.Services.StructuralSearch.PatternLexer.TryParsePattern(String pattern, IDictionary`2 placeholders, StructuralSearchPatternParams params, Func`2 createElement, Int32 realShift, Boolean createUnknownPlaceholders, Boolean deleteUnusedPlaceholders)
       at JetBrains.ReSharper.Psi.Services.Html.StructuralSearch.HtmlStructuralSearchPatternBuilder.DoParsePattern(String pattern, IDictionary`2 placeholders, StructuralSearchPatternParams params)
       at JetBrains.ReSharper.Psi.Services.Html.StructuralSearch.HtmlStructuralSearchPattern.GeneratePlaceholders(Boolean deleteUnusedPlaceholders, Dictionary`2 metaplaceholders)
       at JetBrains.ReSharper.Psi.Services.Html.StructuralSearch.HtmlStructuralSearchPattern.CreateMatcher()
       at JetBrains.ReSharper.Features.StructuralSearch.StructuralSearchMatcherManager.GetOrCreateMatcher(IStructuralSearchPattern pattern, IStructuralSearchPatternBuilder builder)
       at JetBrains.ReSharper.Features.StructuralSearch.PredefinedCustomPatternsManager.InitMatchers[TL]()
       at JetBrains.ReSharper.Features.StructuralSearch.PredefinedCustomPatternsManager.GetMatchersFor[T]()
       at JetBrains.ReSharper.Features.Web.StructuralSearch.Html.HtmlPredefinedPatternsStage.<CreateProcess>d__0.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at JetBrains.ReSharper.Daemon.Impl.DaemonProcessBase.<>c__DisplayClass12.<DoHighlighting>b__4(IDaemonStage stage)
       at JetBrains.Application.Threading.Tasks.TaskBarrier.<>c__DisplayClass7.<>c__DisplayClass9.<EnqueueDependentJobs>b__5()
       at JetBrains.Application.Threading.Tasks.TaskHost.<>c__DisplayClass11.<Create>b__e(Object state)
  InnerException:


... and later a lot of JetBrains.ReSharper.Psi.Parsing.UnexpectedToken exceptions

Any ideas?
3 comments
Comment actions Permalink

I've created a sample solution to reproduce the exceptions (see attached ReSharperAspHighlightingTest.zip).



Attachment(s):
ReSharperAspHighlightingTest.zip
0
Comment actions Permalink

This is because the CSS configuration data isn't loaded. When trying to parse the aspx file in the test, ReSharper creates multiple PSI trees for the file - aspx, C#, JS and CSS. Those trees are then processed by the appropriate daemon stages, and the CSS daemon requires the configuration to be loaded. Because the test runs in the bin\Debug folder of your project, all of the assemblies are copied there, but the CSS config data isn't. It isn't even distributed with the SDK (we don't notice this internally as our tests run in a build folder which is an exact copy of the install dir, and that includes the CSS config data).

The easy solution is to copy the CSS folder from the ReSharper install dir to the bin\Debug folder. Perhaps set up a pre- or post-build step to do this automatically. I've raised an issue against the SDK to fix this in future releases: http://youtrack.jetbrains.com/issue/RSRP-416928

0
Comment actions Permalink

OK. many, many thanks for your answer and the created issue!

0

Please sign in to leave a comment.