It seems that "Declare Class" has some issues with .NET Standard projects (perhaps even .NET Core; but I haven't seen it do that on .NET Framework projects yet):
C#System.AggregateException : One or more errors occurred. ---> Object reference not set to an instance of an object.
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeWorker(Func`1 getFromDocument,IProgressTracker progressTracker,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.<>c__DisplayClass18_0.<InvokeCore>b__0()
at Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformAction(IExtensionManager extensionManager,Object extension,Action action)
---> (Inner Exception #0) System.NullReferenceException : Object reference not set to an instance of an object.
at DevExpress.CodeAnalysis.Refactorings.Actions.AddDocumentOperation.Apply(Workspace workspace,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CodeActions.CodeActionOperation.TryApply(Workspace workspace,IProgressTracker progressTracker,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ProcessOperations(Workspace workspace,ImmutableArray`1 operations,IProgressTracker progressTracker,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ApplyAsync(<Unknown Parameters>)<---
To trigger this, simply open a .NET Standard project (or create a new one), then type code as follows (in case it matters: targetting .NET Standard 1.3, no multi-target):
C#var test = new TestClass();
Afterwards place the Cursor on "TestClass" and invoke "Declare" > "Declare Class" (make sure to not leave the cursor at the end of the line, which only shows the Visual Studio "Generate class 'TestClass' in new file" etc. refactorings).
As result, the provider crashes with the yellow bar on top that says "'DeclareProvider' encountered an error and has been disabled".
This also created two files: TestClass.cs and TestClass1.cs. The former has a complete and useful declaration of the class (as expected), but the latter has an unformatted string of text that lacks any kind of whitespace and doesn't even compile:
C#namespaceNetStandardLib{publicclassTestClass{publicTestClass(){}}}
This is on latest Visual Studio 2017 Community Edition (15.7.5).
Hello,
We have reproduced this issue. Please give us some time to fix it. You will be automatically notified once we do this.