Skip to content

Commit

Permalink
Add nag message when project.json projects are opened
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinCampbell committed Jul 21, 2017
1 parent 762d020 commit a76c6de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function activate(context: vscode.ExtensionContext): any {
ensureRuntimeDependencies(extension, logger, reporter)
.then((success : boolean) => {
// activate language services
OmniSharp.activate(context, reporter);
OmniSharp.activate(context, reporter, _channel);

// register JSON completion & hover providers for project.json
context.subscriptions.push(addJSONProviders());
Expand Down
21 changes: 20 additions & 1 deletion src/omnisharp/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { addAssetsIfNecessary, AddAssetResult } from '../assets';
import { sum, safeLength } from '../common';
import * as utils from './utils';

export function activate(context: vscode.ExtensionContext, reporter: TelemetryReporter) {
export function activate(context: vscode.ExtensionContext, reporter: TelemetryReporter, channel: vscode.OutputChannel) {
const documentSelector: vscode.DocumentSelector = {
language: 'csharp',
scheme: 'file' // only files from disk
Expand Down Expand Up @@ -88,6 +88,25 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
}));
}

// After server is started (and projects are loaded), check to see if there are
// any project.json projects. If so, notify the user about migration.
disposables.push(server.onServerStart(() => {
utils.requestWorkspaceInformation(server)
.then(workspaceInfo => {
if (workspaceInfo.DotNet && workspaceInfo.DotNet.Projects.length > 0) {
const shortMessage = 'project.json is no longer a supported project format for .NET Core applications.';
const detailedMessage = "Warning: project.json is no longer a supported project format for .NET Core applications. Update to the latest version of .NET Core (https://aka.ms/netcoredownload) and use ‘dotnet migrate’ to upgrade your project (see https://aka.ms/netcoremigrate for details).";
const moreDetailItem: vscode.MessageItem = { title: 'More Detail' };

vscode.window.showWarningMessage(shortMessage, moreDetailItem)
.then(item => {
channel.appendLine(detailedMessage);
channel.show();
});
}
});
}));

// Send telemetry about the sorts of projects the server was started on.
disposables.push(server.onServerStart(() => {
let measures: { [key: string]: number } = {};
Expand Down

6 comments on commit a76c6de

@chadbramwell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I disable this nag?

@DustinCampbell
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no plan to add a way to disable the 'project.json' migration nag. Eventually, project.json will simply stop working in C# for VS Code. So, the easiest way to get rid of the message is to migrate your project forward.

@chadbramwell
Copy link

@chadbramwell chadbramwell commented on a76c6de Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I do that when I'm required to use an old version of Unity which auto-generates these files?

To clarify my position: I don't use VS code for compiling/debugging but I often use it to quickly pull up files/directories for rapid iteration. I'd love to not have these nag windows get in my face every time I want to browse some files or examine diffs with git.

@DustinCampbell
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is with Unity generating 'project.json' files for UWP, correct? This is the first request we've had for this since adding that nag message last August. I believe this is a point-in-time problem, correct?

@chadbramwell
Copy link

@chadbramwell chadbramwell commented on a76c6de Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is with Unity generating 'project.json' files for UWP, correct?

That is correct.

This is the first request we've had for this since adding that nag message last August. I believe this is a point-in-time problem, correct?

This is an issue I've lived with for a while. I've finally decided today to try and find a solution. Adding '"csharp.suppressDotnetRestoreNotification": true' to my user settings fixed the rest of my issues.

@DustinCampbell
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can certainly remove this and rebuild the extension for UWP work.

Please sign in to comment.