Граф коммитов

14531 Коммитов

Автор SHA1 Сообщение Дата
Dustin Campbell db6c3d8647 Lazily import ILoggerProviders
This change makes our AbstractLoggerFactory take a set of Lazy<ILoggerProvider> instances and only realize them the first time a message is logged.
2024-04-29 15:33:35 -07:00
David Wengier 15df83a559
Convert assert to a log message (#10317)
Seems like timing changes in the system have resulted in us recieving
generated C# for miscellaneous project files, so we're hitting this
assert more often now. Removing it doesn't seem to have any noticable
effects, we get the right C# content for the right projects soon after,
as the server loads information.
2024-04-30 07:12:51 +10:00
Dustin Campbell b8fa0bca5c
Make RazorProjectService operations atomic (#10322)
The work I did to make all of the public entry points on
`RazorProjectService` async did so by breaking up the operations in
multiple tasks. The operations themselves can't interleave because a
semaphore gates just one operation at a time. However, the updates to
the `ProjectSnapshotManager` made by each operation _can_ interleave
with other updates to the `ProjectSnapshotManager`.

This change ensures that all of the `RazorProjectService` operations are
atomic WRT to the `ProjectSnapshotManger` by running each operation
within a call to `ProjectSnapshotManager.UpdateAsync(...)`. In addition,
I've taken a suggestion from @ryzngard to change when the miscellaneous
files project is added to the `ProjectSnapshotManager` in the language
server. Before this change, the misc files project would be added by the
first call to `ISnapshotResolver.GetMiscellaneousProjectAsync(...)`.
Now, it's added during `SnapshotResolver` initialization. This allows
`GetMiscellaneousProjectAsync(...)` to become a synchronous method,
which has the positive effect allowing many of the downstream callers to
be synchronous as well. Ultimately, this allows all of the
`RazorProjectService` operations to be implemented synchronously, which
helps ensure that they are actually atomic.
2024-04-29 13:49:48 -07:00
Dustin Campbell 00b1ea3e32 Rename method back to OnInitializedAsync 2024-04-29 13:13:43 -07:00
Dustin Campbell c9efa48ac3 Improve signatures of TryCreate methods 2024-04-29 11:27:27 -07:00
Dustin Campbell 313b8c682a Improve signature of TryResolveAllProjects 2024-04-29 10:28:45 -07:00
Dustin Campbell 0b4c78b869 Renamed OnInitializedAsync to InitializeAsync 2024-04-29 10:17:05 -07:00
Dustin Campbell 6ef629c8ae Make RazorFileChangeDetectorManager implement IOnInitialized 2024-04-29 10:15:34 -07:00
Dustin Campbell e3594cdd70 Make SnapshotResolver implement IOnInitialized 2024-04-29 10:11:19 -07:00
Dustin Campbell 1d7c262550 Make IOnInitialized a bit more general purpose 2024-04-29 09:20:15 -07:00
David Wengier 9a5a795a29 Use the LSP project engine factory
The default factory can't handle the misc files project, so these tests were failing unnecessarily
2024-04-29 16:35:57 +10:00
David Wengier 26cc4aad7c Add new test to fully represent the real world case
This was mostly covered by other tests, but they used the project snapshot manager directly.
2024-04-29 16:35:57 +10:00
David Wengier 4e7a407325 Update tests to represent their current behaviour 2024-04-29 16:35:57 +10:00
David Wengier 4238928446 Restore functionality in tests
Sadly most of the usage of the AddDocument method, that took advantage of the fact that it would try to find a real project, were tests.
2024-04-29 16:35:57 +10:00
David Wengier 31c9282dbf Remove unnecessary code
Since the misc files project is not a real project, no razor file will actually be a child of it. It's not even a real path that exists on disk
2024-04-29 16:35:57 +10:00
David Wengier 8a31344b9a Remove unnecessary local method 2024-04-29 16:35:57 +10:00
David Wengier 499eff368b Rename methods 2024-04-29 16:35:56 +10:00
David Wengier 8b1dabe342 If we don't have any project info, then just add to the misc files project 2024-04-29 14:00:36 +10:00
David Wengier d5d5f0c8e9
Logger isn't nullable (#10316)
Minor cleanup
2024-04-27 08:31:12 +10:00
David Wengier b2d0c4ed6f
Minor improvements to integration tests (#10319)
* Reference the razor extension from the integration test project, so
that making a code change and running a test from Test Explorer actually
causes the new code to be tested
* Manually initialize the `ThrowingTraceListener` because it seems the
module initializer doesn't work with our wacky test infra (and I choose
not to try to understand the latter :P)
* Up the log level of the test logger, so the Text Explorer output
includes the full logs of the test run
2024-04-27 08:30:56 +10:00
David Wengier e66b0a5018
Add log message and assert to identify PRISM bug (#10318)
Seems like we're hitting the error condition here, and so our
integration tests are firing telemetry for it. Would be better to debug
fail so we get a failed test and know what the scenario is.
2024-04-27 08:30:41 +10:00
Dustin Campbell 7cfb0cffb9
Allow tests to specify delay for WorkspaceProjectStateChangeDetector (#10297)
Fixes #10295

`WorkspaceProjectStateChangeDetector` tests were taking an extra long
time to run because they didn't specify a faster delay `TimeSpan` to the
detector's `AsyncBatchingWorkQueue`.
2024-04-26 14:59:27 -07:00
Dustin Campbell 27f8be95e1 Remove unneeded ArgumentNullException 2024-04-26 14:11:01 -07:00
Dustin Campbell 91b1f876dc Convert ResolveDocumentInAnyProject to Try* method 2024-04-26 14:04:23 -07:00
Dustin Campbell d05d81c256 Make RazorProjectService operations atomic
The RazorProjectService APIs (e.g. AddDocumentAsync, UpdateProjectAsync, etc.) were chunked into multiple tasks and awaits. That means that other updates to the ProjectSnapshotManager could be interleaved with them. This change ensures that the operations are atomic (as far as the ProjectSnapshotManager is concerned) by running each within a call to ProjectSnapshotManager.UpdateAsync(...). Because of other changes to make CPU-bound async work synchronous the operations themselves can be made synchronous.
2024-04-26 14:04:23 -07:00
Dustin Campbell 654c7148d8 Remove async from RazorRequestContextFactory.CreateRequestContextAsync
This method now runs synchronously.
2024-04-26 14:04:23 -07:00
Dustin Campbell a198c29a12 Make IDocumentContextFactory synchronous
Now that ISnapshotResolver is synchronous, there's no reason for IDocumentContextFactory to be synchronous.
2024-04-26 14:04:17 -07:00
Dustin Campbell e027f2e5e9 Make ISnapshotResolver.ResolveDocumentInAnyProject synchronous 2024-04-26 11:35:48 -07:00
Dustin Campbell 8b6e05bb7b Make ISnapshotResolver.TryResolveAllProjects synchronous
This extension method no longer has awaits and can be made synchronous. In addition, the cancellation token can be removed.
2024-04-26 11:23:33 -07:00
Dustin Campbell 56356efb01 Make ISnapshotResolver.GetMiscellaneousProject synchronous
Now that the misc project is guaranteed to be in the project snapshot manager, the operation to retrieve the misc project can be made synchronous.
2024-04-26 11:17:42 -07:00
Dustin Campbell b95e00f8db Add misc project when server is initialized
This change updates SnapshotResolver with an InitializeAsync method that is called when the LSP "initialized" endpoint is handled. When initialized, the SnapshotResolver adds the misc project to the ProjectSnapshotManager. Tests have been updated to call InitializeAsync whenever a SnapshotResolver is created.
2024-04-26 11:08:11 -07:00
David Wengier b12682faee Minor improvements to integration tests 2024-04-26 16:45:09 +10:00
David Wengier 5bd7adfee2 Add log message and assert to identify PRISM bug 2024-04-26 16:43:06 +10:00
David Wengier 227acd6c8d Convert assert to a log message 2024-04-26 16:39:55 +10:00
David Wengier 238e824838 Logger isn't null 2024-04-26 16:29:11 +10:00
Dustin Campbell 77b30be775
Add missing attribute (#10311)
Integration tests all failed with a MEF composition error
2024-04-25 08:23:23 -07:00
David Wengier 83bbc336bd Add missing attribute 2024-04-25 21:36:14 +10:00
Alex Gavrilov 831f212cc3
Unit tests for RazorProjectInfoEndpointPublisher (#10281)
* Unit tests for RazorProjectInfoEndpointPublisher

* Removing unnessary using directive

* Minor formatting/rename cleanup

* 'using' cleanup

* Use test accessors per CR suggestion

* Misc renames per CR suggestions

* Change test accessor to follow reference doc in Roslyn
2024-04-25 08:25:11 +00:00
Dustin Campbell 0108bcc330
Make ProjectSnapshotManagerDispatcher an implementation detail and restrict access (#10291)
This is the final change to remove the ProjectSnapshotManagerDispatcher
virus that has spread throughout Razor.
2024-04-24 15:42:25 -07:00
Dustin Campbell a48c278f4c Merge branch 'main' into fully-remove-dispatcher 2024-04-24 15:13:41 -07:00
Dustin Campbell 097bb8d79a
Unify logging on `Microsoft.CodeAnalysis.Razor.Logging.ILogger` (#10296)
Fixes #10294

This pull request removes Razor tooling's alternative logging systems
(`IErrorReporter` and `RazorLogger`) and unifies on
`Microsoft.CodeAnalysis.Razor.Logging.ILogger`. As part of this, I've
introduced a `RazorActivityLog` service that can be MEF imported in the
VS layer to write to the VS activity log. Also, I've add an
`ILoggerProvider` in the VS layer that automatically writes any warnings
and errors to the activity log.
2024-04-24 14:21:28 -07:00
Andrew Hall 9acd5266cc
Allow multiple forms for the featureflag script (#10304)
It was tedious to get the actual argument right, so this checks for multiple forms and tries to correct them.

The following should be supported now:

eng\scripts\featureflag.ps1 -set -flag Razor.LSP.ForceRuntimeCodeGeneration -enable
eng\scripts\featureflag.ps1 -set -flag Razor\LSP\ForceRuntimeCodeGeneration -enable
eng\scripts\featureflag.ps1 -set -flag FeatureFlags.Razor.LSP.ForceRuntimeCodeGeneration -enable
eng\scripts\featureflag.ps1 -set -flag FeatureFlags\Razor\LSP\ForceRuntimeCodeGeneration -enable

This should make copying the value from code easier to figure out. We could also just assume feature flags start with FeatureFlags\LSP\Razor\<flagname> but that's not inherantly true, just happens to be for now.
2024-04-24 14:17:59 -07:00
Dustin Campbell 6f8c5bddbc Clean up type construction a bit 2024-04-24 13:04:51 -07:00
Dustin Campbell 0646c2de96 Don't add timestamp when logging to the VS activity log 2024-04-24 11:43:34 -07:00
Dustin Campbell f761a2d100 Improve LogLevel checking 2024-04-24 11:39:13 -07:00
David Wengier 8558b71b16
Don't get capabilities before they're available (#10300)
Fixes a PRISM fault I can't find the link for right now
2024-04-24 11:11:22 +10:00
David Wengier 89f1eaa1e8
More integration test work (#10293)
This PR:

* Re-enables logging to test output for integration tests
* Increases the log level of all logging during integration tests
* Actually deploys Razor to the experimental hive so we're testing Razor
main on VS main
* Previously, without that change, we were testing using the integration
test source from main, against whatever bits were inserted in VS main.
This seemed odd to me, but if anyone thinks that is a desired test
scenario let me know. It does explain a couple of failures I remember
seeing ages ago, which was the reason I had backed out the logging in
the first place
* Output VS version info to the pipeline logs
2024-04-24 11:11:04 +10:00
David Wengier 2e4b22bc64
Fix integration tests, and razor, by using the correct cancellation token (#10301)
This reverts commit d76f5c59d9, humorously
entitled "Check correct CancellationToken". Sorry @DustinCampbell 😁

What was happening was that when a project change was queued up, we
cancelled any previous work that was in play. This used to check the
disposal cancellation token, so we didn't try to release a semaphore
that was disposed. The change to use the passed in cancellation token
meant we never released the semaphore.
2024-04-24 09:30:03 +10:00
David Wengier c5c07d612c Revert "Check correct CancellationToken"
This reverts commit d76f5c59d9.
2024-04-24 09:17:56 +10:00
David Wengier 6006454562 Add a bunch more trace logs to workspace state generator 2024-04-24 09:17:25 +10:00