├── .editorconfig ├── .gitattributes ├── .github └── workflows │ ├── build.yml │ ├── main.yml │ └── pull_request.yml ├── .gitignore ├── .gitmodules ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── Directory.Build.props ├── Directory.Packages.props ├── LICENSE ├── MSBuildLanguageServer.Tests ├── .editorconfig ├── Completion │ ├── CompletionTests.cs │ └── MSBuildCompletionTests.cs ├── Extensions │ ├── CompletionListExtensions.cs │ └── TestServerExtensions.cs ├── HoverTests.cs ├── Import │ ├── AbstractLanguageServerProtocolTests.Edited.cs │ ├── AbstractLanguageServerProtocolTests.cs │ ├── ServerInitializationTests.cs │ ├── Stubs.cs │ └── UseExportProviderAttribute.cs └── MSBuildLanguageServer.Tests.csproj ├── MSBuildLanguageServer ├── .editorconfig ├── DisplayElementRenderer.cs ├── GlobalSuppressions.cs ├── Handler │ ├── CodeActions │ │ ├── CodeActionHandler.cs │ │ ├── CodeActionKindExtensions.cs │ │ ├── CodeActionResolveData.cs │ │ ├── CodeActionResolveHandler.cs │ │ ├── UnsupportedCodeActionOperationException.cs │ │ └── WorkspaceEditExtensions.cs │ ├── Completion │ │ ├── CompletionClientCapabilities.cs │ │ ├── CompletionHandler.cs │ │ ├── CompletionItems │ │ │ ├── MSBuildCompletionItem.cs │ │ │ ├── MSBuildCultureCompletionItem.cs │ │ │ ├── MSBuildLcidCompletionItem.cs │ │ │ ├── MSBuildNewGuidCompletionItem.cs │ │ │ ├── MSBuildReferenceExpressionCompletionItem.cs │ │ │ ├── MSBuildSdkCompletionItem.cs │ │ │ ├── OrderedPackageVersionCompletionItem.cs │ │ │ ├── PackageCompletionItem.cs │ │ │ ├── XmlClosingTagCompletionItem.cs │ │ │ ├── XmlCompletionItem.cs │ │ │ └── XmlEntityCompletionItem.cs │ │ ├── CompletionRenderSettings.cs │ │ ├── CompletionRenderer.cs │ │ ├── CompletionResolveHandler.cs │ │ ├── ILspCompletionItem.cs │ │ ├── MSBuildCompletionDocsProvider.cs │ │ ├── MSBuildCompletionItemKind.cs │ │ ├── MSBuildXmlCompletionDataSource.cs │ │ ├── PackageCompletionDocsProvider.cs │ │ ├── XmlCommitKind.cs │ │ ├── XmlCompletionDataSource.cs │ │ └── XmlToLspCompletionItemKind.cs │ ├── DocumentDiagnosticsHandler.cs │ ├── HoverHandler.cs │ ├── LocationHelpers.cs │ ├── Navigation │ │ ├── FindAllReferencesHandler.cs │ │ └── GoToDefinitionHandler.cs │ └── WorkDoneProgressExtensions.cs ├── Import │ ├── ExportProviderBuilder.cs │ ├── Extensions.cs │ ├── LspWorkspaceManager.cs │ ├── LspWorkspaceManagerFactory.cs │ ├── MSBuildLanguageServer.cs │ ├── MefLanguageServices.cs │ ├── Program.cs │ ├── ProtocolConversions.cs │ ├── RequestContext.cs │ ├── Stubs.cs │ └── VisualStudioMefHostServices.cs ├── InternalsVisibleTo.cs ├── KnownVSCodeImages.cs ├── LspLoggerExtensions.cs ├── MSBuildCapabilitiesProvider.cs ├── MSBuildGlyph.cs ├── MSBuildLanguageServer.csproj ├── MSBuildLanguageServerFactory.cs ├── MSBuildWorkspace.cs.WIP ├── NuGetSearchExports.cs ├── Parser │ ├── LspMSBuildParser.cs │ ├── LspMSBuildParserService.cs │ ├── LspMSBuildParserServiceFactory.cs │ ├── LspTextExtensions.cs │ ├── LspXmlParser.cs │ ├── LspXmlParserService.cs │ ├── LspXmlParserServiceFactory.cs │ ├── NullBackgroundParseService.cs │ └── TextPositionConversionExtensions.cs ├── Program.cs ├── Services │ ├── CodeActionCacheFactory.cs │ ├── CompletionListCacheFactory.cs │ ├── FunctionTypeProviderServiceFactory.cs │ ├── LspNavigationService.FindReferencesSearchJob.cs │ ├── LspNavigationService.cs │ ├── LspNavigationServiceFactory.cs │ └── MSBuildRuntimeServiceFactory.cs └── Workspace │ ├── EditorDocumentState.cs │ ├── LspEditorDocument.cs │ ├── LspEditorWorkspace.cs │ └── LspEditorWorkspaceFactory.cs ├── MonoDevelop.MSBuild.Editor.Common ├── CodeActions │ ├── EditTextActionOperationExtensions.cs │ ├── MSBuildChangeAnnotation.cs │ ├── MSBuildCodeAction.cs │ ├── MSBuildCodeActionContext.cs │ ├── MSBuildCodeActionKind.cs │ ├── MSBuildCodeActionKindExtensions.cs │ ├── MSBuildCodeActionProvider.cs │ ├── MSBuildCodeActionService.cs │ ├── MSBuildDocumentCreate.cs │ ├── MSBuildDocumentDelete.cs │ ├── MSBuildDocumentEdit.cs │ ├── MSBuildDocumentEditBuilder.Edit.cs │ ├── MSBuildDocumentEditBuilder.cs │ ├── MSBuildDocumentEditBuilderCodeAction.cs │ ├── MSBuildDocumentRename.cs │ ├── MSBuildSpellChecker.cs │ ├── MSBuildWorkspaceEdit.cs │ ├── MSBuildWorkspaceEditOperation.cs │ └── SourceTextExtensions.cs ├── CodeFixes │ ├── AppendNoWarnFixProvider.cs │ ├── ChangeMisspelledNameFixProvider.cs │ ├── FixMultitargetingPluralizationFixProvider.cs │ ├── RemoveMSBuildAllProjectsAssignmentFixProvider.cs │ └── RemovePropertyOrMetadataWithDefaultValueFixProvider.cs ├── Completion │ ├── CompletionHelpers.cs │ ├── MSBuildCompletionTrigger.cs │ ├── PackageCompletion.cs │ └── SdkCompletion.cs ├── InternalsVisibleTo.cs ├── MonoDevelop.MSBuild.Editor.Common.csproj ├── Navigation │ └── MSBuildNavigationHelpers.cs ├── Refactorings │ ├── ElementInsertionSpanExtensions.cs │ ├── ExtractExpression │ │ ├── ExpressionNodeExtraction.cs │ │ ├── ExtractExpressionRefactoringProvider.ExtractExpressionAction.cs │ │ └── ExtractExpressionRefactoringProvider.cs │ ├── MSBuildElementExtensions.cs │ ├── SplitGroupRefactoringProvider.cs │ └── UseAttributesForMetadataRefactoringProvider.cs └── Roslyn │ ├── IRoslynCompilationProvider.cs │ ├── RoslynFunctionInfo.cs │ ├── RoslynFunctionTypeProvider.cs │ ├── RoslynHelpers.cs │ └── RoslynTaskMetadataBuilder.cs ├── MonoDevelop.MSBuild.Editor.VisualStudio ├── Analysis │ ├── IWpfDifferenceViewerExtensions.cs │ ├── WpfDifferenceViewElementFactory.cs │ └── WpfMSBuildSuggestedAction.cs ├── Logging │ ├── JsonSettingsStorage.cs │ ├── MSBuildEditorExtensionTelemetry.cs │ ├── MSBuildEditorLogger.cs │ ├── MSBuildEditorLoggerProvider.cs │ ├── MSBuildEditorSettingsStorage.cs │ ├── MSBuildEditorTelemetrySettings.cs │ ├── MSBuildExtensionLogger.cs │ ├── MSBuildOutputPaneWriter.cs │ ├── UserIdentifiableValueHasher.cs │ └── UserIdentifiableValueSanitizer.cs ├── MSBuildEditorFactory.cs ├── MSBuildEditorVisualStudioPackage.cs ├── MSBuildLanguageService.cs ├── MSBuildTaskCenterProgressReporter.cs ├── MonoDevelop.MSBuild.Editor.VisualStudio.csproj ├── Options │ ├── MSBuildTelemetryOptions.cs │ ├── MSBuildTelemetryOptionsPage.cs │ ├── MSBuildTelemetryOptionsUIElement.xaml │ ├── MSBuildTelemetryOptionsUIElement.xaml.cs │ └── OptionsResources.xaml ├── PackageConsts.cs ├── PackageFeedRegistryProvider.cs ├── Properties │ ├── AssemblyInfo.cs │ └── DesignTimeResources.xaml ├── Resources.resx ├── RoslynFindReferences │ ├── AbstractFindUsagesCustomColumnDefinition.cs │ ├── Contexts │ │ └── TableDataSourceFindUsagesContext.cs │ ├── DependencyObjectExtensions.cs │ ├── Entries │ │ ├── Entry.cs │ │ ├── FoundReferenceEntry.cs │ │ └── SimpleMessageEntry.cs │ ├── FindUsagesValueUsageInfoColumnDefinition.cs │ ├── IFindAllReferencesWindowExtensions.cs │ ├── ISupportNavigation.cs │ ├── NameMetadata.cs │ ├── Placeholders.cs │ ├── ReferenceEqualityComparer.cs │ ├── StreamingFindUsagesPresenter.cs │ ├── TableEntriesSnapshot.cs │ └── WpfClassificationExtensions.cs ├── RoslynImport │ ├── Interop │ │ ├── ComAggregate.cs │ │ ├── ComEventSink.cs │ │ ├── IComWrapperFixed.cs │ │ └── WrapperPolicy.cs │ └── LanguageService │ │ ├── AbstractEditorFactory.cs │ │ ├── AbstractLanguageService.IVsAutoOutliningClient.cs.cs │ │ ├── AbstractLanguageService`2.IVsLanguageInfo.cs │ │ ├── AbstractLanguageService`2.VsCodeWindowManager.cs │ │ ├── AbstractLanguageService`2.cs │ │ ├── AbstractPackage.cs │ │ ├── AbstractPackage`2.cs │ │ └── LanguageService.cs ├── SetRegistrationOptionAttribute.cs ├── VSPackage.resx ├── VisualStudioCompilationProvider.cs ├── VisualStudioMSBuildEditorHost.cs ├── WpfMarkdown │ ├── WpfMarkdownExtensions.cs │ ├── WpfMarkdownHelper.cs │ ├── WpfMarkdownListScope.cs │ ├── WpfMarkdownStyles.cs │ ├── WpfMarkdownTextBlock.cs │ └── WpfTextMarkdownRenderer.cs ├── languages.pkgdef └── source.extension.vsixmanifest ├── MonoDevelop.MSBuild.Editor ├── Analysis │ ├── IMSBuildSuggestedActionFactory.cs │ ├── MSBuildSuggestedActionSource.cs │ ├── MSBuildSuggestedActionsSourceProvider.cs │ ├── MSBuildWorkspaceEditExtensions.cs │ └── PreviewChangesService.cs ├── Commands │ ├── MSBuildCachingResolver.cs │ ├── MSBuildFindReferencesCommandHandler .cs │ ├── MSBuildGoToDefinitionCommandHandler.cs │ └── MSBuildHelpCommandHandler.cs ├── Completion │ ├── MSBuildCompletionCommitManager.cs │ ├── MSBuildCompletionCommitManagerProvider.cs │ ├── MSBuildCompletionContext.cs │ ├── MSBuildCompletionDocumentationProvider.cs │ ├── MSBuildCompletionItemManager.cs │ ├── MSBuildCompletionSource.NuGetSearchInfo.cs │ ├── MSBuildCompletionSource.cs │ └── MSBuildCompletionSourceProvider.cs ├── DisplayElementFactory.cs ├── ExportedRoslynFunctionTypeProvider.cs ├── Exports │ ├── .editorconfig │ ├── ExportedFileSystem.cs │ ├── ExportedNuGetDiskFeedFactory.cs │ ├── ExportedNuGetV3ServiceFeedFactory.cs │ ├── ExportedPackageFeedFactorySelector.cs │ ├── ExportedPackageSearchManager.cs │ └── ExportedWebRequestFactory.cs ├── GlobalSuppressions.cs ├── HighlightReferences │ ├── MSBuildHighlightReferencesTagger.cs │ └── MSBuildHighlightReferencesTaggerProvider.cs ├── Host │ ├── FindReferencesContext.cs │ ├── FoundReference.cs │ ├── IMSBuildEditorHost.cs │ └── IStreamingFindReferencesPresenter.cs ├── InternalsVisibleTo.cs ├── MSBuildBackgroundParser.cs ├── MSBuildBraceCompletion.cs ├── MSBuildContentType.cs ├── MSBuildContentTypeProvider.cs ├── MSBuildDiagnosticTag.cs ├── MSBuildEnvironmentLogger.cs ├── MSBuildParseResult.cs ├── MSBuildParserProvider.cs ├── MSBuildTextMateTagger.cs ├── MSBuildValidationTagger.cs ├── MSBuildValidationTaggerProvider.cs ├── MonoDevelop.MSBuild.Editor.csproj ├── Navigation │ ├── MSBuildNavigableSymbol.cs │ ├── MSBuildNavigableSymbolSource.cs │ ├── MSBuildNavigableSymbolSourceProvider.cs │ └── MSBuildNavigationService.cs ├── QuickInfo │ ├── MSBuildDiagnosticQuickInfoSource.cs │ ├── MSBuildDiagnosticQuickInfoSourceProvider.cs │ ├── MSBuildQuickInfoSource.cs │ └── MSBuildQuickInfoSourceProvider.cs ├── RoslynShims.cs ├── TextStructure │ ├── MSBuildTextStructureNavigator.cs │ └── MSBuildTextStructureNavigatorProvider.cs └── VSEditorOptionsReader.cs ├── MonoDevelop.MSBuild.Tests.Editor ├── CodeFixes │ ├── AppendNoWarnCodeFixTest.cs │ └── FixMultitargetingPluralizationCodeFixTests.cs ├── Completion │ ├── MSBuildCommitTests.cs │ ├── MSBuildCompletionTests.cs │ ├── TestCompilationProvider.cs │ ├── TestFileSystem.cs │ └── TestSchemaProvider.cs ├── DisplayElementTests.cs ├── MSBuildEditorCatalog.cs ├── MSBuildEditorTest.cs ├── MSBuildExpandSelectionTests.cs ├── MSBuildFindReferencesTests.cs ├── MSBuildQuickInfoTests.cs ├── MSBuildResolverTests.cs ├── MSBuildTestEnvironment.cs ├── Mocks │ ├── TestMSBuildEditorHost.cs │ ├── TestMSBuildEnvironment.cs │ └── TestPackageFeedRegistry.cs ├── MonoDevelop.MSBuild.Tests.Editor.csproj ├── Refactorings │ ├── ExtractExpressionTests.cs │ └── MSBuildEditorTestExtensions.cs └── TestLoggers.cs ├── MonoDevelop.MSBuild.Tests ├── Analyzers │ ├── AppendNoWarnAnalyzerTest.cs │ ├── CoreDiagnosticTests.cs │ ├── DoNotAssignMSBuildAllProjectsAnalyzerTest.cs │ ├── IncompleteDocumentTests.cs │ └── TaskDiagnosticTests.cs ├── Completion │ ├── ExxpressionCompletionTests.cs │ └── MSBuildExpressionCompletionTest.cs ├── CultureHelperTests.cs ├── DescriptionTests.cs ├── ExpressionCompletionTests.cs ├── FrameworkInfoTests.cs ├── Helpers │ ├── MSBuildDocumentTest.Diagnostics.cs │ ├── MSBuildDocumentTest.Parsing.cs │ ├── MSBuildDocumentTest.Text.cs │ ├── MSBuildDocumentTest.cs │ ├── MSBuildTestHelpers.cs │ ├── MSBuildTestLogHelpers.cs │ ├── NUnitExtensions.cs │ └── TestSchemaProvider.cs ├── InternalsVisibleTo.cs ├── MSBuildConditionTests.cs ├── MSBuildExpressionTests.cs ├── MSBuildIdentifierTests.cs ├── MSBuildImportEvaluationTests.cs ├── MonoDevelop.MSBuild.Tests.csproj ├── PackageSearch │ ├── .editorconfig │ ├── Mocks │ │ ├── MockFileSystem.cs │ │ └── MockWebRequestFactory.cs │ ├── NuGetV2ServiceFeedTests.cs │ └── TestFiles │ │ ├── GetPackageInfo.CommonLogging.xml │ │ ├── GetPackageNames.CommonLogging.xml │ │ └── GetPackageVersions.CommonLogging.xml ├── SchemaTests.cs └── XmlEscapingTests.cs ├── MonoDevelop.MSBuild ├── Analysis │ ├── AttributeDiagnosticContext.cs │ ├── ElementDiagnosticContext.cs │ ├── MSBuildAnalysisContext.cs │ ├── MSBuildAnalysisContextImpl.cs │ ├── MSBuildAnalysisSession.cs │ ├── MSBuildAnalyzer.cs │ ├── MSBuildAnalyzerAttribute.cs │ ├── MSBuildAnalyzerDriver.cs │ ├── MSBuildDiagnostic.cs │ ├── MSBuildDiagnosticDescriptor.cs │ ├── MSBuildDiagnosticExtensions.cs │ ├── MSBuildDiagnosticSeverity.cs │ └── PropertyWriteDiagnosticContext.cs ├── Analyzers │ ├── AppendNoWarnAnalyzer.cs │ ├── DoNotAssignMSBuildAllProjectsAnalyzer.cs │ ├── PackageReferenceConditionAnalyzer.cs │ ├── RuntimeIdentifierOrRuntimeIdentifiersAnalyzer.cs │ └── TargetFrameworksOrTargetFrameworkAnalyzer.cs ├── CurrentProcessMSBuildEnvironment.cs ├── DisplayText.cs ├── Dom │ ├── MSBuildAttribute.cs │ ├── MSBuildDomExtensions.cs │ ├── MSBuildElement.cs │ └── MSBuildObject.cs ├── Evaluation │ ├── EvaluatedValue.cs │ ├── IMSBuildEvaluationContext.cs │ ├── IMSBuildEvaluator.cs │ ├── Imported │ │ ├── .editorconfig │ │ ├── AssemblyResources.cs │ │ ├── AssemblyUtilities.cs │ │ ├── CommunicationsUtilities.cs │ │ ├── Constants.cs │ │ ├── DebugUtils.cs │ │ ├── ErrorUtilities.cs │ │ ├── EscapingUtilities.cs │ │ ├── ExceptionHandling.cs │ │ ├── Expander.Ported.cs │ │ ├── Expander.cs │ │ ├── FileUtilities.cs │ │ ├── FileUtilitiesRegex.cs │ │ ├── IConstrainedEqualityComparer.cs │ │ ├── InternalErrorException.cs │ │ ├── IntrinsicFunctions.Override.cs │ │ ├── IntrinsicFunctions.cs │ │ ├── MSBuildNameIgnoreCaseComparer.cs │ │ ├── NativeMethodsShared.cs │ │ ├── NuGetFrameworkWrapper.cs │ │ ├── ResourceUtilities.cs │ │ ├── Resources │ │ │ ├── Strings.resx │ │ │ └── Strings.shared.resx │ │ ├── SimpleVersion.cs │ │ ├── StringBuilderCache.cs │ │ └── Stubs.cs │ ├── MSBuildCollectedValuesEvaluationContext.cs │ ├── MSBuildEvaluatorExtensions.cs │ ├── MSBuildFileEvaluationContext.cs │ └── MSBuildProjectEvaluationContext.cs ├── IMSBuildEnvironment.cs ├── IMSBuildFileSystem.cs ├── ITaskMetadataBuilder.cs ├── InternalsVisibleTo.cs ├── Language │ ├── AnnotationTable.cs │ ├── Annotations.cs │ ├── CoreDiagnosticProperty.cs │ ├── CoreDiagnostics.cs │ ├── CultureHelper.cs │ ├── ExpressionCompletion.cs │ ├── ExpressionDiagnostics.cs │ ├── Expressions │ │ ├── ExpressionComparison.cs │ │ ├── ExpressionError.cs │ │ ├── ExpressionExtensions.cs │ │ ├── ExpressionFunctions.cs │ │ ├── ExpressionItem.cs │ │ ├── ExpressionItemNode.cs │ │ ├── ExpressionList.cs │ │ ├── ExpressionMetadata.cs │ │ ├── ExpressionNode.cs │ │ ├── ExpressionOptions.cs │ │ ├── ExpressionParser.Conditions.cs │ │ ├── ExpressionParser.cs │ │ ├── ExpressionProperty.cs │ │ ├── ExpressionPropertyNode.cs │ │ ├── ExpressionText.cs │ │ ├── IContainerExpression.cs │ │ └── ListExpression.cs │ ├── IFunctionTypeProvider.cs │ ├── ISymbol.cs │ ├── IVersionableSymbol.cs │ ├── Import.cs │ ├── KnownCulture.cs │ ├── MSBuildDocument.cs │ ├── MSBuildDocumentValidator.cs │ ├── MSBuildDocumentVisitor.cs │ ├── MSBuildIdentifier.cs │ ├── MSBuildImportResolver.cs │ ├── MSBuildInferredSchema.cs │ ├── MSBuildNavigation.cs │ ├── MSBuildParserContext.cs │ ├── MSBuildReferenceCollector.cs │ ├── MSBuildReferenceKind.cs │ ├── MSBuildResolveResult.cs │ ├── MSBuildResolver.cs │ ├── MSBuildRootDocument.cs │ ├── MSBuildSymbolExtensions.cs │ ├── MSBuildToolsVersion.cs │ ├── PropertyValueCollector.cs │ ├── References │ │ └── MSBuildKnownValueReferenceCollector.cs │ ├── Syntax │ │ ├── MSBuildAttributeName.cs │ │ ├── MSBuildAttributeSyntax.cs │ │ ├── MSBuildElementName.cs │ │ ├── MSBuildElementSyntax.cs │ │ ├── MSBuildSyntax.cs │ │ └── MSBuildSyntaxKind.cs │ ├── TimeMetrics.cs │ ├── TypeNameValidation.cs │ ├── Typesystem │ │ ├── BaseSymbol.cs │ │ ├── ConstantSymbol.cs │ │ ├── CustomTypeInfo.cs │ │ ├── CustomTypeValue.cs │ │ ├── DotNetTypeMap.cs │ │ ├── FileOrFolderInfo.cs │ │ ├── FrameworkInfo.cs │ │ ├── FunctionInfo.cs │ │ ├── FunctionInfoExtensions.cs │ │ ├── IntrinsicFunctions.cs │ │ ├── ItemInfo.cs │ │ ├── MSBuildValueKind.cs │ │ ├── MetadataInfo.cs │ │ ├── PropertyInfo.cs │ │ ├── TargetInfo.cs │ │ ├── TaskInfo.cs │ │ ├── ValueKindExtensions.cs │ │ ├── ValueKindInfo.cs │ │ └── VariableInfo.cs │ └── WellKnownTaskFactory.cs ├── MSBuildSdkReference.cs ├── MonoDevelop.MSBuild.csproj ├── NoopTaskMetadataBuilder.cs ├── NullMSBuildEnvironment.cs ├── OneOrMany.cs ├── Options │ ├── MSBuildCompletionOptions.cs │ └── MSBuildEditorOptions.cs ├── PackageSearch │ ├── .editorconfig │ ├── Contracts │ │ ├── IDependencyManager.cs │ │ ├── IPackageFeed.cs │ │ ├── IPackageFeedFactory.cs │ │ ├── IPackageFeedFactorySelector.cs │ │ ├── IPackageFeedRegistryProvider.cs │ │ ├── IPackageFeedSearchJob.cs │ │ ├── IPackageFeedSearcher.cs │ │ ├── IPackageInfo.cs │ │ ├── IPackageNameSearchResult.cs │ │ ├── IPackageQueryConfiguration.cs │ │ ├── IPackageSearchManager.cs │ │ ├── IPackageVersionSearchResult.cs │ │ └── PackageType.cs │ ├── Feeds │ │ ├── Disk │ │ │ ├── NuGetDiskFeedFactory.cs │ │ │ ├── NuGetPackageMatcher.cs │ │ │ ├── NuGetV2DiskFeed.cs │ │ │ └── NuGetV3DiskFeed.cs │ │ ├── FeedKind.cs │ │ ├── NuSpecReader.cs │ │ ├── PackageFeedFactoryBase.cs │ │ ├── PackageFeedFactorySelector.cs │ │ ├── PackageInfo.cs │ │ ├── PackageQueryConfiguration.cs │ │ └── Web │ │ │ ├── NuGetV2ServiceFeed.cs │ │ │ └── NuGetV3ServiceFeed.cs │ ├── IO │ │ ├── FileSystem.cs │ │ ├── IFileSystem.cs │ │ ├── IWebRequestFactory.cs │ │ ├── WebRequestFactory.cs │ │ └── WebRequestFactoryExtensions.cs │ ├── PackageSearchHelpers.cs │ ├── Search │ │ ├── PackageFeedSearchJob.cs │ │ ├── PackageNameSearchResult.cs │ │ ├── PackageSearchManager.cs │ │ └── PackageVersionSearchResult.cs │ └── SemanticVersion.cs ├── Resources │ ├── ElementDescriptions.resx │ ├── HelpDescriptions.resx │ └── HelpUrls.resx ├── Schema │ ├── BuiltInSchema.cs │ ├── BuiltInSchemaId.cs │ ├── DescriptionFormatter.cs │ ├── FrameworkInfoProvider.PlatformId.cs │ ├── FrameworkInfoProvider.cs │ ├── IMSBuildSchema.cs │ ├── MSBuildCompletionExtensions.cs │ ├── MSBuildIntrinsics.cs │ ├── MSBuildSchema.SchemaLoadState.cs │ ├── MSBuildSchema.TypeInfoLoader.cs │ ├── MSBuildSchema.cs │ ├── MSBuildSchemaExtensions.cs │ ├── MSBuildSchemaLoadError.cs │ ├── MSBuildSchemaProvider.cs │ └── MSBuildSchemaWriter.cs ├── Schemas │ ├── AnalyzerWarningCodes.buildschema.json │ ├── Android.buildschema.json │ ├── Appx.buildschema.json │ ├── AspNetCore.buildschema.json │ ├── AspireAppHost.buildschema.json │ ├── AspireDashboardSdk.buildschema.json │ ├── AspireHostingOrchestration.buildschema.json │ ├── AspireHostingSdk.buildschema.json │ ├── CSharp.buildschema.json │ ├── CSharpWarningCodes.buildschema.json │ ├── CodeAnalysis.buildschema.json │ ├── CommonTargets.buildschema.json │ ├── Cpp.buildschema.json │ ├── GenerateAssemblyInfo.buildschema.json │ ├── GrpcProtobuf.buildschema.json │ ├── ILCompiler.buildschema.json │ ├── ILLink.buildschema.json │ ├── JavaScript.buildschema.json │ ├── NetSdk.buildschema.json │ ├── NuGet.buildschema.json │ ├── NuGetPack.buildschema.json │ ├── ProjectSystemCps.buildschema.json │ ├── ProjectSystemMps.buildschema.json │ ├── RazorSdk.buildschema.json │ ├── Roslyn.buildschema.json │ ├── StyleRuleCodes.buildschema.json │ ├── ValidatePackage.buildschema.json │ ├── VisualBasic.buildschema.json │ ├── WindowsDesktop.buildschema.json │ └── buildschema.json ├── SdkResolution │ ├── DefaultSdkResolver.cs │ ├── Imported │ │ ├── .editorconfig │ │ ├── CoreCLRAssemblyLoader.cs │ │ ├── MSBuildLoadContext.cs │ │ ├── MSBuildSdkResolver.cs │ │ └── SdkResolverManifest.cs │ ├── MSBuildSdkResolver.SdkLoggerImpl.cs │ ├── MSBuildSdkResolver.SdkResolverContextImpl.cs │ ├── MSBuildSdkResolver.SdkResultFactoryImpl.cs │ ├── MSBuildSdkResolver.SdkResultImpl.cs │ ├── MSBuildSdkResolver.cs │ └── SdkInfo.cs ├── Util │ ├── CollectionExtensions.cs │ ├── FilePathUtils.cs │ ├── MSBuildEscaping.cs │ ├── MSBuildLoggerExtensions.cs │ ├── Platform.cs │ └── XmlEscaping.cs ├── WellKnownProperties.cs └── Workspace │ ├── MSBuildFileExtension.cs │ ├── MSBuildFileKind.cs │ └── MSBuildFileKindExtensions.cs ├── MonoDevelop.MSBuildEditor.sln ├── MonoDevelop.MSBuildEditor ├── Analysis │ ├── CocoaDifferenceViewElementFactory.cs │ ├── CocoaMSBuildSuggestedAction.cs │ └── ICocoaDifferenceViewerExtensions.cs ├── MSBuildCommandHandler.cs ├── MSBuildCommands.cs ├── MonoDevelop.MSBuildEditor.csproj ├── MonoDevelopCompilationProvider.cs ├── MonoDevelopMSBuildEditorHost.cs ├── MonoDevelopMSBuildEnvironment.cs ├── MonoDevelopSdkResolver.cs ├── MonoDevelopStreamingFindReferencesPresenter.cs ├── PackageSearch │ └── MonoDevelopPackageFeedRegistry.cs ├── Pads │ ├── DocumentWithMimeTypeTracker.cs │ ├── MSBuildImportNavigator.cs │ └── MSBuildImportNavigatorPad.cs ├── Properties │ ├── AddinInfo.cs │ └── Manifest.addin.xml ├── Templates │ ├── Project.xft.xml │ └── Project.xml └── Tests │ └── MonoDevelop.MSBuildEditor.Tests.csproj ├── NoVSEditor.slnf ├── NuGet.Config ├── README.md ├── RELEASES.md ├── TODO.md ├── XsdSchemaImporter ├── .editorconfig ├── ConstrainedXmlResolver.cs ├── DownloadCache.cs ├── MSBuildSchemaUtils.cs ├── MSBuildXsdSchemaReader.cs ├── Program.cs ├── XElementExtensions.cs └── XsdSchemaImporter.csproj ├── art ├── icon-128.png ├── icon-32.png ├── icon-32.svg ├── icon.png └── icon.svg ├── docs └── PrivacyStatement.md ├── images ├── completion.gif ├── condition-completion.png ├── find-references.png ├── import-tooltip.png ├── property-function-completion.png ├── tooltip.png ├── validation.png ├── vs-code-fixes.png ├── vs-condition-completion.png ├── vs-expression-completion.png ├── vs-find-references-cropped.png ├── vs-find-references.png ├── vs-packageref-completion.gif ├── vs-quick-info-cropped.png ├── vs-quick-info.png ├── vs-schema.png └── vs-validation.png ├── msbuild-editor-vscode ├── .editorconfig ├── .eslintrc.json ├── .vscode-test.mjs ├── .vscodeignore ├── CHANGELOG.md ├── README.md ├── esbuild.js ├── images │ ├── vscode-code-fix.png │ ├── vscode-condition-completion.png │ ├── vscode-expression-completion.png │ ├── vscode-find-references.png │ ├── vscode-nowarn-completion.png │ ├── vscode-packageref-completion.png │ ├── vscode-quick-info.png │ ├── vscode-schema.png │ └── vscode-validation.png ├── language-configuration.json ├── package-lock.json ├── package.json ├── package.nls.json ├── src │ ├── completionItemMiddleware.ts │ ├── extension.ts │ ├── hoverMiddleware.ts │ ├── options.ts │ ├── roslynImport │ │ ├── common.ts │ │ ├── compositeDisposable.ts │ │ ├── coreclrDebug │ │ │ └── util.ts │ │ ├── disposable.ts │ │ ├── eventStream.ts │ │ ├── lsptoolshost │ │ │ ├── commands.ts │ │ │ ├── dotnetRuntimeExtensionResolver.ts │ │ │ ├── optionChanges.ts │ │ │ ├── roslynLanguageClient.ts │ │ │ ├── roslynLanguageServer.ts │ │ │ ├── roslynProtocol.ts │ │ │ ├── showToastNotification.ts │ │ │ └── uriConverter.ts │ │ ├── main.ts │ │ ├── omnisharp │ │ │ ├── eventType.ts │ │ │ └── loggingEvents.ts │ │ ├── packageManager │ │ │ └── absolutePath.ts │ │ └── shared │ │ │ ├── constants │ │ │ ├── IHostExecutableResolver.ts │ │ │ └── hostExecutableInformation.ts │ │ │ ├── observables │ │ │ └── createOptionStream.ts │ │ │ ├── observers │ │ │ └── optionChangeObserver.ts │ │ │ ├── options.ts │ │ │ ├── platform.ts │ │ │ ├── reportIssue.ts │ │ │ └── utils │ │ │ ├── dotnetInfo.ts │ │ │ └── getDotnetInfo.ts │ └── test │ │ └── extension.test.ts ├── syntaxes │ ├── OSSREADME.json │ └── msbuild.tmLanguage.json └── tsconfig.json ├── private.snk ├── sample └── todo.csproj └── version.json /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.sln eol=crlf 3 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Main 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | concurrency: 9 | group: ci-main-${{ github.ref }}-1 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | build: 14 | uses: ./.github/workflows/build.yml -------------------------------------------------------------------------------- /.github/workflows/pull_request.yml: -------------------------------------------------------------------------------- 1 | name: Pull Request 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | concurrency: 9 | group: ci-pr-${{ github.ref }}-1 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | build: 14 | uses: ./.github/workflows/build.yml -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.userprefs 2 | bin 3 | obj 4 | packages 5 | *.suo 6 | .DS_Store 7 | .vs 8 | *.user 9 | *.binlog 10 | out 11 | node_modules 12 | .vscode-test 13 | dist 14 | 15 | # these are copied during vsix packaging 16 | /msbuild-editor-vscode/LICENSE 17 | /msbuild-editor-vscode/server 18 | /msbuild-editor-vscode/*.vsix 19 | /msbuild-editor-vscode/icon.png 20 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "MonoDevelop.Xml"] 2 | path = MonoDevelop.Xml 3 | url = https://github.com/mhutch/MonoDevelop.Xml.git 4 | [submodule "external/NuGet.Client"] 5 | path = external/NuGet.Client 6 | url = https://github.com/NuGet/NuGet.Client.git 7 | [submodule "external/roslyn"] 8 | path = external/roslyn 9 | url = https://github.com/dotnet/roslyn.git 10 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint", 6 | "amodio.tsl-problem-matcher", 7 | "ms-vscode.extension-test-runner", 8 | "ms-dotnettools.csharp", 9 | "streetsidesoftware.code-spell-checker", 10 | "editorconfig.editorconfig", 11 | "connor4312.esbuild-problem-matchers", 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run VS Code Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}/msbuild-editor-vscode", 15 | ], 16 | "env": { 17 | "MSBUILD_LANGUAGE_SERVER_PATH": "${workspaceFolder}/artifacts/bin/MSBuildLanguageServer/debug/MSBuildLanguageServer.dll", 18 | }, 19 | "outFiles": [ 20 | "${workspaceFolder}/msbuild-editor-vscode/dist/**/*.js" 21 | ], 22 | "sourceMaps": true, 23 | "preLaunchTask": "Build VS Code Extension in Background", 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | $(MSBuildThisFileDirectory)private.snk 6 | latest 7 | embedded 8 | $(MSBuildProjectName) 9 | true 10 | true 11 | 12 | -------------------------------------------------------------------------------- /MSBuildLanguageServer.Tests/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | [*.cs] 4 | 5 | # revert settings to match roslyn style better 6 | indent_style = space 7 | trim_trailing_whitespace = false 8 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 9 | csharp_space_between_method_call_name_and_opening_parenthesis = false 10 | csharp_space_after_keywords_in_control_flow_statements = false 11 | 12 | # Newline settings 13 | csharp_new_line_before_open_brace = methods, properties, control_blocks, types 14 | csharp_new_line_before_else = false 15 | csharp_new_line_before_catch = false 16 | csharp_new_line_before_finally = false 17 | 18 | # VS threading analyzer triggers on imported roslyn code 19 | dotnet_diagnostic.VSTHRD002.severity = none 20 | dotnet_diagnostic.VSTHRD003.severity = none 21 | dotnet_diagnostic.VSTHRD103.severity = none 22 | dotnet_diagnostic.VSTHRD110.severity = none -------------------------------------------------------------------------------- /MSBuildLanguageServer.Tests/Extensions/CompletionListExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | using LSP = Roslyn.LanguageServer.Protocol; 7 | 8 | namespace MonoDevelop.MSBuild.LanguageServer.Tests; 9 | 10 | static class CompletionListExtensions 11 | { 12 | public static void AssertContains(this LSP.CompletionList list, string name) 13 | { 14 | var item = list.Items.FirstOrDefault(i => i.Label == name); 15 | Assert.NotNull(item); // "Completion result is missing item '{0}'", name); 16 | } 17 | 18 | public static void AssertNonEmpty([NotNull] this LSP.CompletionList? list) 19 | { 20 | Assert.NotNull(list); 21 | Assert.NotEmpty(list.Items); 22 | } 23 | 24 | public static void AssertItemCount([NotNull] this LSP.CompletionList? list, int expectedCount) 25 | { 26 | Assert.NotNull(list); 27 | Assert.Equal(expectedCount, list.Items.Length); 28 | } 29 | 30 | public static void AssertDoesNotContain(this LSP.CompletionList list, string name) 31 | { 32 | var item = list.Items.FirstOrDefault(i => i.Label == name); 33 | Assert.Null(item); //, "Completion result has unexpected item '{0}'", name); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MSBuildLanguageServer.Tests/Import/AbstractLanguageServerProtocolTests.Edited.cs: -------------------------------------------------------------------------------- 1 | // heavily edited methods from 2 | // https://github.com/dotnet/roslyn/blob/1a4c3f429fe13a2e928c800cebbf93154447095a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs 3 | 4 | // Licensed to the .NET Foundation under one or more agreements. 5 | // The .NET Foundation licenses this file to you under the MIT license. 6 | // See the LICENSE file in the project root for more information. 7 | 8 | using Microsoft.CodeAnalysis.Test.Utilities; 9 | using Microsoft.CodeAnalysis.Editor.UnitTests; 10 | 11 | namespace Roslyn.Test.Utilities 12 | { 13 | partial class AbstractLanguageServerProtocolTests 14 | { 15 | protected static readonly TestComposition EditorFeaturesLspComposition = EditorTestCompositions.LanguageServerProtocolEditorFeatures; 16 | 17 | protected static readonly TestComposition FeaturesLspComposition = EditorTestCompositions.LanguageServerProtocol; 18 | protected virtual TestComposition Composition => EditorFeaturesLspComposition; 19 | } 20 | } -------------------------------------------------------------------------------- /MSBuildLanguageServer/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | [*.cs] 4 | 5 | # revert settings to match roslyn style better 6 | indent_style = space 7 | trim_trailing_whitespace = false 8 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 9 | csharp_space_between_method_call_name_and_opening_parenthesis = false 10 | csharp_space_after_keywords_in_control_flow_statements = false 11 | 12 | # Newline settings 13 | csharp_new_line_before_open_brace = methods, properties, control_blocks, types 14 | csharp_new_line_before_else = false 15 | csharp_new_line_before_catch = false 16 | csharp_new_line_before_finally = false 17 | 18 | # VS threading analyzer triggers on imported roslyn code 19 | dotnet_diagnostic.VSTHRD002.severity = none 20 | dotnet_diagnostic.VSTHRD003.severity = none 21 | dotnet_diagnostic.VSTHRD103.severity = none 22 | dotnet_diagnostic.VSTHRD110.severity = none -------------------------------------------------------------------------------- /MSBuildLanguageServer/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | [assembly: SuppressMessage("MicrosoftCodeAnalysisCorrectness", "RS1024:Symbols should be compared for equality", Justification = "", Scope = "member", Target = "~M:Roslyn.Utilities.GeneratedCodeUtilities.IsGeneratedSymbolWithGeneratedCodeAttribute(Microsoft.CodeAnalysis.ISymbol,Microsoft.CodeAnalysis.INamedTypeSymbol)~System.Boolean")] 9 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/CodeActions/CodeActionResolveData.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Text.Json.Serialization; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.CodeActions; 7 | 8 | class CodeActionResolveData 9 | { 10 | [JsonPropertyName("resultId")] 11 | [JsonRequired] 12 | public long ResultId { get; init; } 13 | 14 | [JsonPropertyName("index")] 15 | [JsonRequired] 16 | public int Index { get; init; } 17 | } 18 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/CodeActions/UnsupportedCodeActionOperationException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.MSBuild.Editor.CodeActions; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.CodeActions; 7 | 8 | class UnsupportedCodeActionOperationException(MSBuildWorkspaceEditOperation? operation, bool isUnknown) : Exception 9 | { 10 | public MSBuildWorkspaceEditOperation? Operation { get; } = operation; 11 | public bool IsUnknown { get; } = isUnknown; 12 | 13 | public override string Message => (IsUnknown || Operation is null) 14 | ? $"Code action returned unknown workspace edit operation '{Operation?.GetType().ToString() ?? "[null]"}'" 15 | : $"Code action returned unsupported workspace edit operation '{Operation.GetType()}'"; 16 | } -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/Completion/CompletionItems/MSBuildNewGuidCompletionItem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Roslyn.LanguageServer.Protocol; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.Completion.CompletionItems; 7 | 8 | class MSBuildNewGuidCompletionItem() : ILspCompletionItem 9 | { 10 | const string label = "New GUID"; 11 | 12 | public bool IsMatch(CompletionItem request) => string.Equals(label, request.Label, StringComparison.Ordinal); 13 | 14 | public async ValueTask Render(CompletionRenderSettings settings, CompletionRenderContext ctx, CancellationToken cancellationToken) 15 | { 16 | var item = new CompletionItem { Label = label }; 17 | 18 | if(settings.IncludeItemKind) 19 | { 20 | item.Kind = MSBuildCompletionItemKind.NewGuid; 21 | } 22 | 23 | if(settings.IncludeDocumentation) 24 | { 25 | item.Documentation = new MarkupContent { 26 | Value = "Inserts a new GUID", 27 | Kind = MarkupKind.Markdown 28 | }; 29 | } 30 | 31 | if(settings.IncludeInsertText) 32 | { 33 | item.InsertText = Guid.NewGuid().ToString("B").ToUpper(); 34 | } 35 | 36 | return item; 37 | } 38 | } -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/Completion/CompletionItems/MSBuildSdkCompletionItem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.MSBuild.SdkResolution; 5 | 6 | using Roslyn.LanguageServer.Protocol; 7 | 8 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.Completion.CompletionItems; 9 | 10 | class MSBuildSdkCompletionItem(SdkInfo info, MSBuildCompletionDocsProvider docsProvider) : ILspCompletionItem 11 | { 12 | string label => info.Name; 13 | 14 | public bool IsMatch(CompletionItem request) => string.Equals(request.Label, label, StringComparison.Ordinal); 15 | 16 | public async ValueTask Render(CompletionRenderSettings settings, CompletionRenderContext ctx, CancellationToken cancellationToken) 17 | { 18 | var item = new CompletionItem { Label = label }; 19 | 20 | if(settings.IncludeItemKind) 21 | { 22 | item.Kind = MSBuildCompletionItemKind.Sdk; 23 | } 24 | 25 | if(settings.IncludeDocumentation && info.Path is string sdkPath) 26 | { 27 | // FIXME: better docs 28 | item.Documentation = new MarkupContent { Kind = MarkupKind.Markdown, Value = $"`{sdkPath}`" }; 29 | } 30 | 31 | return item; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/Completion/CompletionItems/XmlEntityCompletionItem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Roslyn.LanguageServer.Protocol; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.Completion.CompletionItems; 7 | 8 | class XmlEntityCompletionItem(string name, string character) : ILspCompletionItem 9 | { 10 | readonly string label = $"&{name};"; 11 | 12 | public bool IsMatch(CompletionItem request) => string.Equals(request.Label, label, StringComparison.Ordinal); 13 | 14 | 15 | //TODO: need to tweak semicolon insertion for XmlCompletionItemKind.Entity 16 | public ValueTask Render(CompletionRenderSettings settings, CompletionRenderContext ctx, CancellationToken cancellationToken) 17 | { 18 | var item = new CompletionItem { Label = label, FilterText = name, Kind = XmlToLspCompletionItemKind.Entity }; 19 | 20 | if(settings.IncludeDocumentation) 21 | { 22 | item.Documentation = $"Escaped '{character}'"; 23 | }; 24 | 25 | return new(item); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/Completion/PackageCompletionDocsProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using ProjectFileTools.NuGetSearch.Contracts; 5 | using ProjectFileTools.NuGetSearch.Feeds; 6 | 7 | using Roslyn.LanguageServer.Protocol; 8 | 9 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.Completion; 10 | 11 | record class PackageCompletionDocsProvider(IPackageSearchManager PackageSearchManager, MSBuildCompletionDocsProvider docsProvider, string? TargetFrameworkSearchParameter) 12 | { 13 | public Task GetPackageDocumentation(string packageId, string? packageVersion, FeedKind feedKind, CancellationToken cancellationToken) 14 | => docsProvider.GetPackageDocumentation(PackageSearchManager, packageId, packageVersion, feedKind, TargetFrameworkSearchParameter, cancellationToken); 15 | } -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/Completion/XmlCommitKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.Completion; 5 | 6 | /// 7 | /// Controls how XML completion items are committed 8 | /// 9 | enum XmlCommitKind 10 | { 11 | Element, 12 | SelfClosingElement, 13 | Attribute, 14 | AttributeValue, 15 | CData, 16 | Comment, 17 | Prolog, 18 | Entity, 19 | ClosingTag, 20 | MultipleClosingTags 21 | } 22 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Handler/Completion/XmlToLspCompletionItemKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Roslyn.LanguageServer.Protocol; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Handler.Completion; 7 | 8 | /// 9 | /// Central location for mapping XML item kinds to values 10 | /// 11 | class XmlToLspCompletionItemKind 12 | { 13 | public const CompletionItemKind ClosingTag = CompletionItemKind.CloseElement; 14 | public const CompletionItemKind Comment = CompletionItemKind.TagHelper; 15 | public const CompletionItemKind CData = CompletionItemKind.TagHelper; 16 | public const CompletionItemKind Prolog = CompletionItemKind.TagHelper; 17 | public const CompletionItemKind Entity = CompletionItemKind.TagHelper; 18 | } 19 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | using MonoDevelop.MSBuild; 6 | 7 | [assembly: InternalsVisibleTo ($"MSBuildLanguageServer.Tests, {IVT.PublicKeyAtt}")] -------------------------------------------------------------------------------- /MSBuildLanguageServer/Parser/LspXmlParserServiceFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Composition; 5 | using Microsoft.CodeAnalysis.LanguageServer; 6 | using Microsoft.CodeAnalysis.LanguageServer.Handler; 7 | using Microsoft.CommonLanguageServerProtocol.Framework; 8 | 9 | using MonoDevelop.MSBuild.Editor.LanguageServer.Workspace; 10 | 11 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Parser; 12 | 13 | [ExportCSharpVisualBasicLspServiceFactory(typeof(LspXmlParserService)), Shared] 14 | class LspXmlParserServiceFactory : ILspServiceFactory 15 | { 16 | public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) 17 | { 18 | var logger = lspServices.GetRequiredService(); 19 | var workspace = lspServices.GetRequiredService(); 20 | return new LspXmlParserService(logger, workspace); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Parser/NullBackgroundParseService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.Xml.Editor.Parsing; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Parser; 7 | 8 | class NullBackgroundParseService : IBackgroundParseService 9 | { 10 | public static NullBackgroundParseService Instance { get; } = new(); 11 | 12 | public bool IsRunning => throw new NotSupportedException(); 13 | 14 | public event EventHandler RunningStateChanged 15 | { 16 | add => throw new NotSupportedException(); 17 | remove => throw new NotSupportedException(); 18 | } 19 | 20 | public void RegisterBackgroundOperation(Task task) 21 | { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Services/CodeActionCacheFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Composition; 5 | 6 | using Microsoft.CodeAnalysis.LanguageServer; 7 | using Microsoft.CodeAnalysis.LanguageServer.Handler; 8 | 9 | using MonoDevelop.MSBuild.Editor.CodeActions; 10 | 11 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Services; 12 | 13 | [ExportCSharpVisualBasicLspServiceFactory(typeof(CodeActionCache)), Shared] 14 | internal class CodeActionCacheFactory : ILspServiceFactory 15 | { 16 | [ImportingConstructor] 17 | public CodeActionCacheFactory() 18 | { 19 | } 20 | 21 | public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) => new CodeActionCache(); 22 | } 23 | 24 | class CodeActionCache : ResolveCache> 25 | { 26 | public CodeActionCache() : base(maxCacheSize: 3) { } 27 | } 28 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Services/CompletionListCacheFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Composition; 5 | 6 | using Microsoft.CodeAnalysis.LanguageServer; 7 | using Microsoft.CodeAnalysis.LanguageServer.Handler; 8 | 9 | using MonoDevelop.MSBuild.Editor.LanguageServer.Handler.Completion; 10 | 11 | using LSP = Roslyn.LanguageServer.Protocol; 12 | 13 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Services; 14 | 15 | [ExportCSharpVisualBasicLspServiceFactory(typeof(CompletionListCache)), Shared] 16 | internal class CompletionListCacheFactory : ILspServiceFactory 17 | { 18 | [ImportingConstructor] 19 | public CompletionListCacheFactory() 20 | { 21 | } 22 | 23 | public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) => new CompletionListCache(); 24 | } 25 | 26 | class CompletionListCache : ResolveCache 27 | { 28 | public CompletionListCache() : base(maxCacheSize: 3) { } 29 | } 30 | 31 | record CompletionListCacheEntry(List Items, CompletionRenderContext Context) { } 32 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Services/LspNavigationService.FindReferencesSearchJob.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.CodeAnalysis.Text; 5 | 6 | using MonoDevelop.Xml.Dom; 7 | 8 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Services; 9 | 10 | partial class LspNavigationService 11 | { 12 | class FindReferencesSearchJob 13 | { 14 | public FindReferencesSearchJob(string filename, XDocument? document, SourceText? sourceText) 15 | { 16 | Filename = filename; 17 | Document = document; 18 | SourceText = sourceText; 19 | } 20 | 21 | public string Filename { get; } 22 | public XDocument? Document { get; set; } 23 | public SourceText? SourceText { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Services/LspNavigationServiceFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Composition; 5 | 6 | using Microsoft.CodeAnalysis.LanguageServer; 7 | using Microsoft.CodeAnalysis.LanguageServer.Handler; 8 | using Microsoft.CommonLanguageServerProtocol.Framework; 9 | 10 | using MonoDevelop.MSBuild.Editor.LanguageServer.Workspace; 11 | 12 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Services; 13 | 14 | [ExportCSharpVisualBasicLspServiceFactory(typeof(LspNavigationService)), Shared] 15 | internal class LspNavigationServiceFactory : ILspServiceFactory 16 | { 17 | [ImportingConstructor] 18 | public LspNavigationServiceFactory() 19 | { 20 | } 21 | 22 | public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) 23 | { 24 | var logger = lspServices.GetRequiredService(); 25 | var extLogger = logger.ToILogger(); 26 | var workspaceService = lspServices.GetRequiredService(); 27 | var xmlParserService = lspServices.GetRequiredService(); 28 | return new LspNavigationService(workspaceService, xmlParserService, extLogger); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Workspace/EditorDocumentState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.CodeAnalysis; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Workspace; 7 | 8 | class EditorDocumentState (DocumentId id, string filePath, TextAndVersion text) 9 | { 10 | public DocumentId Id => id; 11 | public string FilePath => filePath; 12 | public TextAndVersion Text => text ?? throw new InvalidOperationException("Text not yet loaded"); 13 | } 14 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Workspace/LspEditorDocument.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.CodeAnalysis; 5 | using Microsoft.CodeAnalysis.Text; 6 | 7 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Workspace; 8 | 9 | class LspEditorDocument 10 | { 11 | EditorDocumentState state; 12 | 13 | public EditorDocumentState CurrentState => state; 14 | 15 | public DocumentId Id => state.Id; 16 | public string FilePath => state.FilePath; 17 | public TextAndVersion Text => state.Text; 18 | 19 | public LspEditorDocument(DocumentId id, string filePath, SourceText initialText) 20 | { 21 | state = new EditorDocumentState(id, filePath, TextAndVersion.Create(initialText, VersionStamp.Default)); 22 | } 23 | 24 | internal void UpdateText (SourceText text) 25 | { 26 | EditorDocumentState oldState = state; 27 | state = new EditorDocumentState ( 28 | oldState.Id, 29 | oldState.FilePath, 30 | TextAndVersion.Create(text, oldState.Text?.Version.GetNewerVersion() ?? VersionStamp.Default) 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MSBuildLanguageServer/Workspace/LspEditorWorkspaceFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Composition; 5 | using Microsoft.CodeAnalysis.LanguageServer; 6 | using Microsoft.CodeAnalysis.LanguageServer.Handler; 7 | 8 | namespace MonoDevelop.MSBuild.Editor.LanguageServer.Workspace; 9 | 10 | [ExportCSharpVisualBasicLspServiceFactory(typeof(LspEditorWorkspace)), Shared] 11 | class LspEditorWorkspaceFactory : ILspServiceFactory 12 | { 13 | public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) 14 | { 15 | return new LspEditorWorkspace(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/MSBuildChangeAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Editor.CodeActions 5 | { 6 | class MSBuildChangeAnnotation (string label) 7 | { 8 | public string Label => label; 9 | 10 | public bool NeedsConfirmation { get; set; } 11 | 12 | public string? Description { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/MSBuildDocumentCreate.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Editor.CodeActions; 5 | 6 | class MSBuildDocumentCreate (string filename) : MSBuildWorkspaceEditOperation (filename) 7 | { 8 | public string? Content { get; set; } 9 | 10 | public bool Overwrite { get; set; } 11 | 12 | public bool IgnoreIfExists { get; set; } 13 | 14 | public MSBuildChangeAnnotation? Annotation { get; set; } 15 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/MSBuildDocumentDelete.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Editor.CodeActions; 5 | 6 | class MSBuildDocumentDelete (string fileOrFolder) : MSBuildWorkspaceEditOperation (fileOrFolder) 7 | { 8 | public string FileOrFolder => Filename; 9 | 10 | public bool Recursive { get; set; } 11 | 12 | public bool IgnoreIfNotExists { get; set; } 13 | 14 | public MSBuildChangeAnnotation? Annotation { get; set; } 15 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/MSBuildDocumentEdit.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.CodeAnalysis.Text; 5 | 6 | using TextSpan = MonoDevelop.Xml.Dom.TextSpan; 7 | 8 | namespace MonoDevelop.MSBuild.Editor.CodeActions; 9 | 10 | class MSBuildDocumentEdit (string filename, SourceText? originalText, MSBuildTextEdit[] textEdits) : MSBuildWorkspaceEditOperation (filename) 11 | { 12 | public MSBuildTextEdit[] TextEdits => textEdits; 13 | 14 | public SourceText? OriginalText { get; } = originalText; 15 | } 16 | 17 | class MSBuildTextEdit(TextSpan range, string newText, TextSpan[]? relativeSelections = null) 18 | { 19 | public string NewText => newText; 20 | 21 | public TextSpan Range => range; 22 | 23 | /// 24 | /// If this edit is in the focused document, then these ranges (relative to the beginning of the ) will be selected after the operation is complete. 25 | /// 26 | public TextSpan[]? RelativeSelections => relativeSelections; 27 | 28 | public MSBuildChangeAnnotation? Annotation { get; set; } 29 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/MSBuildDocumentRename.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Editor.CodeActions; 5 | 6 | class MSBuildDocumentRename (string oldFilename, string newFilename) : MSBuildWorkspaceEditOperation (newFilename) 7 | { 8 | public string OldFilename => oldFilename; 9 | public string NewFilename => Filename; 10 | 11 | public bool Overwrite { get; set; } 12 | 13 | public bool IgnoreIfExists { get; set; } 14 | 15 | public MSBuildChangeAnnotation? Annotation { get; set; } 16 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/MSBuildWorkspaceEdit.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.CodeActions 7 | { 8 | class MSBuildWorkspaceEdit (IEnumerable? operations = null) 9 | { 10 | public IList Operations => new List (operations ?? []); 11 | 12 | public string? FocusFile { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/MSBuildWorkspaceEditOperation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Editor.CodeActions 5 | { 6 | class MSBuildWorkspaceEditOperation (string filename) 7 | { 8 | public string Filename => filename; 9 | } 10 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/CodeActions/SourceTextExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.CodeAnalysis.Text; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.CodeActions; 7 | 8 | static class SourceTextExtensions 9 | { 10 | public static string? GetLineBreakTextForLineContainingOffset (this SourceText text, int offset) 11 | { 12 | var currentLine = text.Lines.GetLineFromPosition (offset); 13 | return text.GetLineBreakTextForLine (currentLine); 14 | } 15 | 16 | public static string? GetLineBreakTextForLine (this SourceText text, TextLine line) 17 | { 18 | int length = line.EndIncludingLineBreak - line.End; 19 | if (length == 0) { 20 | return null; 21 | } 22 | if (length == 1) { 23 | return text[line.End].ToString (); 24 | } 25 | return $"{text[line.End]}{text[line.End + 1]}"; 26 | } 27 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | using MonoDevelop.MSBuild; 6 | 7 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuild.Tests, {IVT.PublicKeyAtt}")] 8 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuild.Tests.Editor, {IVT.PublicKeyAtt}")] 9 | [assembly: InternalsVisibleTo ($"MSBuildLanguageServer.Tests, {IVT.PublicKeyAtt}")] 10 | 11 | [assembly: InternalsVisibleTo ($"MSBuildLanguageServer, {IVT.PublicKeyAtt}")] 12 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuild.Editor, {IVT.PublicKeyAtt}")] 13 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuild.Editor.VisualStudio, {IVT.PublicKeyAtt}")] 14 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuildEditor, {IVT.PublicKeyAtt}")] 15 | [assembly: InternalsVisibleTo ($"Microsoft.Ide.LanguageService.MSBuild, PublicKey=0024000004800000940000000602000000240000525341310004000001000100675da410943cdcf89a2bbd3716e451b3c35c0de9278a874e06d143dbc861f7b4d21771131177e413290078b98615421b2bb9ac25c14021c4e2c7b967407b5ea96417317ff8bdb1ef34e0d63f5965bdf92841bdaae505987af712a2e1951b2ff76a16d211e0d5ae2c444f55dbd0a3c0f5bed051af0cf7bae49114c4e0c527c4ed")] 16 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/Roslyn/IRoslynCompilationProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.CodeAnalysis; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.Roslyn 7 | { 8 | /// 9 | /// Allows consumers of to control how it loads 10 | /// assemblies. 11 | /// 12 | public interface IRoslynCompilationProvider 13 | { 14 | MetadataReference CreateReference (string assemblyPath); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.Common/Roslyn/RoslynHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.CodeAnalysis; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.Roslyn 7 | { 8 | static class RoslynHelpers 9 | { 10 | public static string GetFullName (this ITypeSymbol symbol) 11 | { 12 | var sb = new System.Text.StringBuilder (); 13 | var ns = symbol.ContainingNamespace; 14 | while (ns != null && !string.IsNullOrEmpty (ns.Name)) { 15 | sb.Insert (0, '.'); 16 | sb.Insert (0, ns.Name); 17 | ns = ns.ContainingNamespace; 18 | } 19 | sb.Append (symbol.Name); 20 | return sb.ToString (); 21 | } 22 | 23 | // loading the docs from roslyn can be expensive, return an empty string and the symbol 24 | // this mean callers have to resolve the docs from the symbol themselves. it's a lot 25 | // simpler to push the async logic to the callers than to make all the BaseInfo.Description 26 | // implementations and usages async 27 | public static DisplayText GetDescription (ISymbol symbol) => new DisplayText ("", symbol); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/Logging/MSBuildEditorLoggerProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System.ComponentModel.Composition; 7 | 8 | using Microsoft.Extensions.Logging; 9 | using Microsoft.Extensions.Logging.Abstractions; 10 | 11 | using Microsoft.VisualStudio.Shell; 12 | using Microsoft.VisualStudio.Utilities; 13 | 14 | using MonoDevelop.Xml.Editor.Logging; 15 | 16 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.Logging; 17 | 18 | [Export (typeof (IEditorLoggerProvider))] 19 | [Name ("MSBuild Editor Logger Provider")] 20 | [ContentType (MSBuildContentType.Name)] 21 | class MSBuildEditorLoggerProvider : IEditorLoggerProvider 22 | { 23 | readonly MSBuildExtensionLogger? loggerFactory; 24 | 25 | [ImportingConstructor] 26 | public MSBuildEditorLoggerProvider (SVsServiceProvider serviceProvider) 27 | { 28 | loggerFactory = (MSBuildExtensionLogger) serviceProvider.GetService (typeof (MSBuildExtensionLogger)); 29 | } 30 | 31 | public ILogger CreateLogger (string categoryName) => loggerFactory?.CreateEditorLogger (categoryName) ?? NullLogger.Instance; 32 | 33 | public void Dispose () { } 34 | } 35 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/Logging/MSBuildEditorSettingsStorage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.IO; 8 | 9 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.Logging; 10 | 11 | class MSBuildEditorSettingsStorage 12 | { 13 | const string editorDataDirectoryName = "MSBuildEditor"; 14 | 15 | readonly string roamingDataDir; 16 | readonly string localDataDir; 17 | 18 | public MSBuildEditorSettingsStorage () 19 | { 20 | localDataDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), editorDataDirectoryName); 21 | roamingDataDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), editorDataDirectoryName); 22 | } 23 | 24 | public string RoamingDataDir => roamingDataDir; 25 | public string LocalDataDir => localDataDir; 26 | } 27 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/MSBuildEditorFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | using Microsoft.VisualStudio.ComponentModelHost; 8 | using Microsoft.VisualStudio.LanguageServices.Implementation; 9 | 10 | namespace MonoDevelop.MSBuild.Editor.VisualStudio 11 | { 12 | [ComVisible (true)] 13 | [Guid (PackageConsts.EditorFactoryGuid)] 14 | class MSBuildEditorFactory : AbstractEditorFactory 15 | { 16 | public MSBuildEditorFactory (IComponentModel componentModel) : base (componentModel) { } 17 | 18 | protected override string ContentTypeName => MSBuildContentType.Name; 19 | 20 | protected override string LanguageName => PackageConsts.LanguageServiceName; 21 | } 22 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/Options/MSBuildTelemetryOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Community.VisualStudio.Toolkit; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.Options; 7 | 8 | public class MSBuildTelemetryOptions : BaseOptionModel 9 | { 10 | public bool IsEnabled { get; set; } = true; 11 | } 12 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/Options/MSBuildTelemetryOptionsPage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | using Microsoft.VisualStudio.Shell; 8 | 9 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.Options; 10 | 11 | [ComVisible (true)] 12 | [Guid (PackageConsts.TelemetryOptionsPageGuid)] 13 | public class MSBuildTelemetryOptionsPage : UIElementDialogPage 14 | { 15 | protected override UIElement Child { 16 | get { 17 | MSBuildTelemetryOptionsUIElement page = new (this); 18 | page.Initialize (); 19 | return page; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/Options/OptionsResources.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 16 | 20 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | // Setting ComVisible to false makes the types in this assembly not visible 4 | // to COM components. If you need to access a type in this assembly from 5 | // COM, set the ComVisible attribute to true on that type. 6 | [assembly: ComVisible (false)] -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/Properties/DesignTimeResources.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 16 | Segoe UI 17 | 9 18 | 19 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynFindReferences/Entries/Entry.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using System.Windows; 4 | 5 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.FindReferences 6 | { 7 | internal partial class StreamingFindUsagesPresenter 8 | { 9 | /// 10 | /// Represents a single entry (i.e. row) in the ungrouped FAR table. 11 | /// 12 | private abstract class Entry 13 | { 14 | protected Entry () 15 | { 16 | } 17 | 18 | public bool TryGetValue (string keyName, out object content) 19 | { 20 | content = GetValueWorker (keyName); 21 | return content != null; 22 | } 23 | 24 | protected abstract object GetValueWorker (string keyName); 25 | 26 | public virtual bool TryCreateColumnContent (string columnName, out FrameworkElement content) 27 | { 28 | content = null; 29 | return false; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynFindReferences/Entries/SimpleMessageEntry.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using System.Threading.Tasks; 4 | using Microsoft.VisualStudio.Shell.TableManager; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.FindReferences 7 | { 8 | internal partial class StreamingFindUsagesPresenter 9 | { 10 | private class SimpleMessageEntry : Entry 11 | { 12 | private readonly string _message; 13 | 14 | private SimpleMessageEntry ( 15 | string message) 16 | : base () 17 | { 18 | _message = message; 19 | } 20 | 21 | public static Task CreateAsync ( 22 | string message) 23 | { 24 | var referenceEntry = new SimpleMessageEntry (message); 25 | return Task.FromResult (referenceEntry); 26 | } 27 | 28 | protected override object GetValueWorker (string keyName) 29 | { 30 | switch (keyName) { 31 | case StandardTableKeyNames.Text: 32 | return _message; 33 | } 34 | 35 | return null; 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynFindReferences/IFindAllReferencesWindowExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using System.Linq; 4 | using Microsoft.VisualStudio.Shell.FindAllReferences; 5 | using Microsoft.VisualStudio.Shell.TableControl; 6 | 7 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.FindReferences 8 | { 9 | internal static class IFindAllReferencesWindowExtensions 10 | { 11 | public static ColumnState2 GetDefinitionColumn (this IFindAllReferencesWindow window) 12 | { 13 | return window.TableControl.ColumnStates.FirstOrDefault ( 14 | s => s.Name == StandardTableColumnDefinitions2.Definition) as ColumnState2; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynFindReferences/ISupportNavigation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.FindReferences 4 | { 5 | internal interface ISupportsNavigation 6 | { 7 | bool TryNavigateTo (bool isPreview); 8 | } 9 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynFindReferences/NameMetadata.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.FindReferences 6 | { 7 | internal class NameMetadata 8 | { 9 | public string Name { get; } 10 | 11 | public NameMetadata (IDictionary data) 12 | { 13 | if (!data.TryGetValue (nameof (Name), out var val)) { 14 | Name = null; 15 | } 16 | Name = (string)val; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynFindReferences/Placeholders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Immutable; 4 | using System.Windows.Controls; 5 | using System.Windows.Documents; 6 | using Microsoft.VisualStudio.Text.Classification; 7 | using MonoDevelop.MSBuild.Editor.Host; 8 | 9 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.FindReferences 10 | { 11 | static class MSBuildOptions 12 | { 13 | public static int DefinitionGroupingPriority { get; set; } 14 | } 15 | 16 | static class FindReferencesExtensions 17 | { 18 | public static HashSet ToSet (this IEnumerable items) => new HashSet (items); 19 | } 20 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynFindReferences/ReferenceEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | using System.Collections.Generic; 4 | using System.Runtime.CompilerServices; 5 | 6 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.FindReferences 7 | { 8 | /// 9 | /// Compares objects based upon their reference identity. 10 | /// 11 | internal class ReferenceEqualityComparer : IEqualityComparer 12 | { 13 | public static readonly ReferenceEqualityComparer Instance = new ReferenceEqualityComparer (); 14 | 15 | private ReferenceEqualityComparer () 16 | { 17 | } 18 | 19 | bool IEqualityComparer.Equals (object a, object b) 20 | { 21 | return a == b; 22 | } 23 | 24 | int IEqualityComparer.GetHashCode (object a) 25 | { 26 | return ReferenceEqualityComparer.GetHashCode (a); 27 | } 28 | 29 | public static int GetHashCode (object a) 30 | { 31 | return RuntimeHelpers.GetHashCode (a); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynImport/LanguageService/AbstractLanguageService.IVsAutoOutliningClient.cs.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | #nullable disable 6 | 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using Microsoft.VisualStudio; 13 | using Microsoft.VisualStudio.TextManager.Interop; 14 | 15 | namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService 16 | { 17 | internal abstract partial class AbstractLanguageService : IVsAutoOutliningClient 18 | { 19 | public int QueryWaitForAutoOutliningCallback(out int fWait) 20 | { 21 | // Normally, the editor automatically loads outlining information immediately. By saying we want to wait, we get to 22 | // control the load point during our view setup. 23 | fWait = 1; 24 | return VSConstants.S_OK; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynImport/LanguageService/AbstractLanguageService`2.IVsLanguageInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | #nullable disable 6 | 7 | using Microsoft.VisualStudio; 8 | using Microsoft.VisualStudio.TextManager.Interop; 9 | 10 | namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService 11 | { 12 | internal abstract partial class AbstractLanguageService : IVsLanguageInfo 13 | { 14 | public int GetCodeWindowManager (IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) 15 | { 16 | ppCodeWinMgr = new VsCodeWindowManager ((TLanguageService)this, pCodeWin); 17 | 18 | return VSConstants.S_OK; 19 | } 20 | 21 | public int GetColorizer (IVsTextLines pBuffer, out IVsColorizer ppColorizer) 22 | { 23 | ppColorizer = null; 24 | 25 | return VSConstants.E_NOTIMPL; 26 | } 27 | 28 | public int GetFileExtensions (out string pbstrExtensions) 29 | { 30 | pbstrExtensions = null; 31 | 32 | return VSConstants.E_NOTIMPL; 33 | } 34 | 35 | public int GetLanguageName (out string bstrName) 36 | { 37 | bstrName = LanguageName; 38 | 39 | return VSConstants.S_OK; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/RoslynImport/LanguageService/LanguageService.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | #nullable disable 6 | 7 | using System; 8 | 9 | namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService 10 | { 11 | internal abstract partial class AbstractLanguageService 12 | { 13 | public abstract Guid LanguageServiceId { get; } 14 | public abstract IServiceProvider SystemServiceProvider { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/SetRegistrationOptionAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | using Microsoft.VisualStudio.Shell; 6 | 7 | namespace MonoDevelop.MSBuild.Editor.VisualStudio 8 | { 9 | [AttributeUsage (AttributeTargets.Class, AllowMultiple = true)] 10 | class SetRegistrationOptionAttribute : RegistrationAttribute 11 | { 12 | readonly string keyName, valueName; 13 | readonly object value; 14 | 15 | public SetRegistrationOptionAttribute (string keyName, string valueName, object value) 16 | { 17 | this.keyName = keyName; 18 | this.valueName = valueName; 19 | this.value = value; 20 | } 21 | 22 | public override void Register (RegistrationContext context) 23 | { 24 | using (Key key = context.CreateKey (keyName)) key.SetValue (valueName, value); 25 | } 26 | 27 | public override void Unregister (RegistrationContext context) => context.RemoveKey (keyName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/VisualStudioCompilationProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | 6 | using Microsoft.CodeAnalysis; 7 | using Microsoft.VisualStudio.Composition; 8 | using Microsoft.VisualStudio.LanguageServices; 9 | 10 | using MonoDevelop.MSBuild.Editor.Roslyn; 11 | 12 | namespace MonoDevelop.MSBuild.Editor.VisualStudio 13 | { 14 | [Export(typeof(IRoslynCompilationProvider))] 15 | class VisualStudioCompilationProvider : IRoslynCompilationProvider 16 | { 17 | [ImportingConstructor] 18 | public VisualStudioCompilationProvider (VisualStudioWorkspace workspace) 19 | { 20 | Workspace = workspace; 21 | } 22 | 23 | public VisualStudioWorkspace Workspace { get; } 24 | 25 | public MetadataReference CreateReference (string assemblyPath) 26 | => Workspace.CreatePortableExecutableReference (assemblyPath, MetadataReferenceProperties.Assembly); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/WpfMarkdown/WpfMarkdownExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | using System.Windows; 8 | using System.Windows.Documents; 9 | 10 | using Markdig.Syntax.Inlines; 11 | 12 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.WpfMarkdown; 13 | 14 | static class WpfMarkdownExtensions 15 | { 16 | public static bool HasLiteralChild (this ContainerInline container, [NotNullWhen (true)] out string? literalText) 17 | { 18 | if (container.FirstChild == container.LastChild && container.FirstChild is LiteralInline literalInline) { 19 | literalText = literalInline.Content.ToString (); 20 | return true; 21 | } else { 22 | literalText = null; 23 | return false; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/WpfMarkdown/WpfMarkdownHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Windows.Controls; 9 | 10 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.WpfMarkdown; 11 | 12 | static class WpfMarkdownHelper 13 | { 14 | /* 15 | public static IEnumerable ToTextBlocks (string markdown) 16 | { 17 | var renderer = new WpfTextMarkdownRenderer (new WpfMarkdownListScope ()); 18 | 19 | var document = Markdig.Markdown.Convert (markdown, renderer); 20 | }*/ 21 | } 22 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor.VisualStudio/WpfMarkdown/WpfMarkdownListScope.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Windows; 9 | using System.Windows.Markup; 10 | 11 | namespace MonoDevelop.MSBuild.Editor.VisualStudio.WpfMarkdown; 12 | 13 | class WpfMarkdownListScope : List, IAddChild 14 | { 15 | public void AddChild (object value) => Add ((FrameworkElement)value); 16 | 17 | public void AddText (string text) => throw new NotSupportedException (); 18 | } 19 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Analysis/IMSBuildSuggestedActionFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.VisualStudio.Language.Intellisense; 5 | using Microsoft.VisualStudio.Text; 6 | using Microsoft.VisualStudio.Text.Editor; 7 | 8 | using MonoDevelop.MSBuild.Editor.CodeActions; 9 | 10 | namespace MonoDevelop.MSBuild.Editor.Analysis 11 | { 12 | //works around the WPF dependency in ISuggestedAction 13 | interface IMSBuildSuggestedActionFactory 14 | { 15 | ISuggestedAction CreateSuggestedAction (PreviewChangesService previewService, ITextView textView, ITextBuffer buffer, MSBuildCodeAction action); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/ExportedRoslynFunctionTypeProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | 6 | using MonoDevelop.MSBuild.Language; 7 | 8 | namespace MonoDevelop.MSBuild.Editor.Roslyn; 9 | 10 | [Export (typeof (IFunctionTypeProvider))] 11 | class ExportedRoslynFunctionTypeProvider : RoslynFunctionTypeProvider 12 | { 13 | [ImportingConstructor] 14 | public ExportedRoslynFunctionTypeProvider (IRoslynCompilationProvider assemblyLoader, MSBuildEnvironmentLogger environmentLogger) 15 | : base (assemblyLoader, environmentLogger.Logger) 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Exports/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | [*.cs] 4 | 5 | # revert settings to match roslyn style better 6 | indent_style = space 7 | trim_trailing_whitespace = false 8 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 9 | csharp_space_between_method_call_name_and_opening_parenthesis = false 10 | csharp_space_after_keywords_in_control_flow_statements = false 11 | 12 | # Newline settings 13 | csharp_new_line_before_open_brace = methods, properties, control_blocks, types 14 | csharp_new_line_before_else = false 15 | csharp_new_line_before_catch = false 16 | csharp_new_line_before_finally = false 17 | 18 | # VS threading analyzer triggers on imported roslyn code 19 | dotnet_diagnostic.VSTHRD002.severity = none 20 | dotnet_diagnostic.VSTHRD003.severity = none 21 | dotnet_diagnostic.VSTHRD103.severity = none 22 | dotnet_diagnostic.VSTHRD110.severity = none -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Exports/ExportedFileSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | using Microsoft.VisualStudio.Utilities; 6 | using ProjectFileTools.NuGetSearch.IO; 7 | 8 | namespace ProjectFileTools.Exports; 9 | 10 | [Export(typeof(IFileSystem))] 11 | [Name("Default File System Implementation")] 12 | internal class ExportedFileSystem : FileSystem 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Exports/ExportedNuGetDiskFeedFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | using Microsoft.VisualStudio.Utilities; 6 | using ProjectFileTools.NuGetSearch.Contracts; 7 | using ProjectFileTools.NuGetSearch.Feeds.Disk; 8 | using ProjectFileTools.NuGetSearch.IO; 9 | 10 | namespace ProjectFileTools.Exports; 11 | 12 | [Export(typeof(IPackageFeedFactory))] 13 | [Name("Default Package Feed Factory")] 14 | internal class ExportedNuGetDiskFeedFactory : NuGetDiskFeedFactory 15 | { 16 | [ImportingConstructor] 17 | public ExportedNuGetDiskFeedFactory(IFileSystem fileSystem) 18 | : base(fileSystem) 19 | { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Exports/ExportedNuGetV3ServiceFeedFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | using Microsoft.VisualStudio.Utilities; 6 | using ProjectFileTools.NuGetSearch.Contracts; 7 | using ProjectFileTools.NuGetSearch.Feeds.Web; 8 | using ProjectFileTools.NuGetSearch.IO; 9 | 10 | namespace ProjectFileTools.Exports; 11 | 12 | [Export(typeof(IPackageFeedFactory))] 13 | [Name("Default NuGet v3 Service Feed Factory")] 14 | internal class ExportedNuGetV3ServiceFeedFactory : NuGetV3ServiceFeedFactory 15 | { 16 | [ImportingConstructor] 17 | public ExportedNuGetV3ServiceFeedFactory(IWebRequestFactory webRequestFactory) 18 | : base(webRequestFactory) 19 | { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Exports/ExportedPackageFeedFactorySelector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Utilities; 7 | using ProjectFileTools.NuGetSearch.Contracts; 8 | using ProjectFileTools.NuGetSearch.Feeds; 9 | 10 | namespace ProjectFileTools.Exports; 11 | 12 | [Export(typeof(IPackageFeedFactorySelector))] 13 | [Name("Default Package Feed Factory Selector")] 14 | internal class ExportedPackageFeedFactorySelector : PackageFeedFactorySelector 15 | { 16 | [ImportingConstructor] 17 | public ExportedPackageFeedFactorySelector([ImportMany] IEnumerable feedFactories) 18 | : base(feedFactories) 19 | { 20 | } 21 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Exports/ExportedPackageSearchManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | using Microsoft.VisualStudio.Utilities; 6 | using ProjectFileTools.NuGetSearch.Contracts; 7 | using ProjectFileTools.NuGetSearch.Search; 8 | 9 | namespace ProjectFileTools.Exports; 10 | 11 | [Export(typeof(IPackageSearchManager))] 12 | [Name("Default Package Search Manager")] 13 | internal class ExportedPackageSearchManager : PackageSearchManager 14 | { 15 | [ImportingConstructor] 16 | public ExportedPackageSearchManager(IPackageFeedRegistryProvider feedRegistry, IPackageFeedFactorySelector factorySelector) 17 | : base(feedRegistry, factorySelector) 18 | { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Exports/ExportedWebRequestFactory.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using Microsoft.VisualStudio.Utilities; 3 | using ProjectFileTools.NuGetSearch.IO; 4 | 5 | namespace ProjectFileTools.Exports; 6 | 7 | [Export(typeof(IWebRequestFactory))] 8 | [Name("Default Web Request Factory")] 9 | internal class ExportedWebRequestFactory : WebRequestFactory 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | [assembly: SuppressMessage ("Usage", "VSTHRD002:Avoid problematic synchronous waits", Justification = "Using threadpool thread to avoid stack overflow", Scope = "member", Target = "~M:Roslyn.Utilities.ObjectReader.ReadValue~System.Object")] 9 | [assembly: SuppressMessage ("Usage", "VSTHRD002:Avoid problematic synchronous waits", Justification = "Using threadpool thread to avoid stack overflow", Scope = "member", Target = "~M:Roslyn.Utilities.ObjectWriter.WriteObject(System.Object,Roslyn.Utilities.IObjectWritable)")] 10 | [assembly: SuppressMessage ("Usage", "VSTHRD002:Avoid problematic synchronous waits", Justification = "Using threadpool thread to avoid stack overflow", Scope = "member", Target = "~M:Roslyn.Utilities.ObjectWriter.WriteArray(System.Array)")] 11 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Host/FindReferencesContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 2 | 3 | // this is based on Roslyn's Microsoft.CodeAnalysis.FindUsages.FindUsagesContext 4 | 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace MonoDevelop.MSBuild.Editor.Host 9 | { 10 | public abstract class FindReferencesContext 11 | { 12 | public virtual CancellationToken CancellationToken { get; } 13 | 14 | protected FindReferencesContext () 15 | { 16 | } 17 | 18 | public virtual Task ReportMessageAsync (string message) => Task.CompletedTask; 19 | 20 | public virtual Task SetSearchTitleAsync (string title) => Task.CompletedTask; 21 | 22 | public virtual Task OnCompletedAsync () => Task.CompletedTask; 23 | 24 | public virtual Task OnReferenceFoundAsync (FoundReference reference) => Task.CompletedTask; 25 | 26 | public virtual Task ReportProgressAsync (int current, int maximum) => Task.CompletedTask; 27 | } 28 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Host/IMSBuildEditorHost.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using Microsoft.VisualStudio.Text; 6 | 7 | namespace MonoDevelop.MSBuild.Editor.Host 8 | { 9 | /// 10 | /// This is assumed to be used only from the UI thread 11 | /// 12 | public interface IMSBuildEditorHost 13 | { 14 | bool OpenFile (string destFile, int destOffset, bool isPreview = false); 15 | void ShowStatusBarMessage (string v); 16 | Dictionary GetOpenDocuments (); 17 | } 18 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | using MonoDevelop.MSBuild; 6 | 7 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuild.Tests, {IVT.PublicKeyAtt}")] 8 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuild.Tests.Editor, {IVT.PublicKeyAtt}")] 9 | 10 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuild.Editor.VisualStudio, {IVT.PublicKeyAtt}")] 11 | [assembly: InternalsVisibleTo ($"MonoDevelop.MSBuildEditor, {IVT.PublicKeyAtt}")] 12 | [assembly: InternalsVisibleTo ($"Microsoft.Ide.LanguageService.MSBuild, PublicKey=0024000004800000940000000602000000240000525341310004000001000100675da410943cdcf89a2bbd3716e451b3c35c0de9278a874e06d143dbc861f7b4d21771131177e413290078b98615421b2bb9ac25c14021c4e2c7b967407b5ea96417317ff8bdb1ef34e0d63f5965bdf92841bdaae505987af712a2e1951b2ff76a16d211e0d5ae2c444f55dbd0a3c0f5bed051af0cf7bae49114c4e0c527c4ed")] 13 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/MSBuildBraceCompletion.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | using Microsoft.VisualStudio.Text.BraceCompletion; 6 | using Microsoft.VisualStudio.Utilities; 7 | 8 | namespace MonoDevelop.MSBuild.Editor 9 | { 10 | [Export (typeof (IBraceCompletionDefaultProvider))] 11 | [ContentType (MSBuildContentType.Name)] 12 | [BracePair ('\'', '\'')] 13 | [BracePair ('"', '"')] 14 | [BracePair ('(', ')')] 15 | [BracePair ('[', ']')] 16 | [BracePair ('{', '}')] 17 | [BracePair ('<', '>')] 18 | class MSBuildBraceCompletionProvider : IBraceCompletionDefaultProvider 19 | { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/MSBuildContentTypeProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | using Microsoft.VisualStudio.Utilities; 6 | 7 | using MonoDevelop.MSBuild.Workspace; 8 | 9 | namespace MonoDevelop.MSBuild.Editor 10 | { 11 | [Export(typeof(IFilePathToContentTypeProvider))] 12 | [Name("MSBuild Content Type Provider")] 13 | [FileExtension("*")] 14 | class MSBuildContentTypeProvider : IFilePathToContentTypeProvider 15 | { 16 | [ImportingConstructor] 17 | public MSBuildContentTypeProvider (IContentTypeRegistryService contentTypeRegistryService) 18 | { 19 | ContentTypeRegistryService = contentTypeRegistryService; 20 | } 21 | 22 | public IContentTypeRegistryService ContentTypeRegistryService { get; } 23 | 24 | public bool TryGetContentTypeForFilePath (string filePath, out IContentType contentType) 25 | { 26 | if (MSBuildFileKindExtensions.GetFileKind (filePath) != MSBuildFileKind.Unknown) { 27 | contentType = ContentTypeRegistryService.GetContentType (MSBuildContentType.Name); 28 | return true; 29 | } 30 | 31 | contentType = null; 32 | return false; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/MSBuildDiagnosticTag.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | using Microsoft.VisualStudio.Text.Adornments; 6 | using Microsoft.VisualStudio.Text.Tagging; 7 | 8 | using MonoDevelop.MSBuild.Analysis; 9 | 10 | namespace MonoDevelop.MSBuild.Editor 11 | { 12 | class MSBuildDiagnosticTag : ErrorTag 13 | { 14 | public MSBuildDiagnosticTag (MSBuildDiagnostic diagnostic) 15 | : base (GetErrorTypeName (diagnostic.Descriptor.Severity), null) 16 | { 17 | Diagnostic = diagnostic; 18 | } 19 | 20 | public MSBuildDiagnostic Diagnostic { get; } 21 | 22 | static string GetErrorTypeName (MSBuildDiagnosticSeverity severity) 23 | { 24 | switch (severity) { 25 | case MSBuildDiagnosticSeverity.Error: 26 | return PredefinedErrorTypeNames.SyntaxError; 27 | case MSBuildDiagnosticSeverity.Warning: 28 | return PredefinedErrorTypeNames.Warning; 29 | case MSBuildDiagnosticSeverity.Suggestion: 30 | return PredefinedErrorTypeNames.HintedSuggestion; 31 | case MSBuildDiagnosticSeverity.None: 32 | return PredefinedErrorTypeNames.Suggestion; 33 | } 34 | throw new ArgumentException ($"Unknown DiagnosticSeverity value {severity}", nameof (severity)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/MSBuildEnvironmentLogger.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | 6 | using Microsoft.Extensions.Logging; 7 | 8 | using MonoDevelop.Xml.Editor.Logging; 9 | 10 | namespace MonoDevelop.MSBuild.Editor 11 | { 12 | /// 13 | /// Shared logger any component can import 14 | /// 15 | [Export] 16 | class MSBuildEnvironmentLogger 17 | { 18 | [ImportingConstructor] 19 | public MSBuildEnvironmentLogger (IEditorLoggerFactory loggerFactory) 20 | { 21 | Factory = loggerFactory; 22 | Logger = loggerFactory.CreateLogger (MSBuildContentType.Name); 23 | } 24 | 25 | public ILogger Logger { get; } 26 | public IEditorLoggerFactory Factory { get; } 27 | } 28 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/MSBuildParseResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | using Microsoft.VisualStudio.Text; 7 | 8 | using MonoDevelop.MSBuild.Analysis; 9 | using MonoDevelop.MSBuild.Language; 10 | 11 | namespace MonoDevelop.MSBuild.Editor.Completion 12 | { 13 | class MSBuildParseResult 14 | { 15 | public MSBuildParseResult (MSBuildRootDocument msbuildDocument, ITextSnapshot snapshot) 16 | { 17 | MSBuildDocument = msbuildDocument; 18 | Snapshot = snapshot; 19 | } 20 | 21 | public MSBuildRootDocument MSBuildDocument { get; } 22 | 23 | public ITextSnapshot Snapshot { get; set; } 24 | } 25 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/MSBuildTextMateTagger.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | using System.Linq; 6 | using Microsoft.VisualStudio.Editor; 7 | using Microsoft.VisualStudio.Text; 8 | using Microsoft.VisualStudio.Text.Tagging; 9 | using Microsoft.VisualStudio.Utilities; 10 | 11 | namespace MonoDevelop.MSBuild.Editor 12 | { 13 | [Export (typeof (ITaggerProvider))] 14 | [TagType (typeof (IClassificationTag))] 15 | [TagType (typeof (IStructureTag))] 16 | [ContentType (MSBuildContentType.Name)] 17 | sealed class MSBuildTextMateTagger : ITaggerProvider 18 | { 19 | [ImportingConstructor] 20 | public MSBuildTextMateTagger (ICommonEditorAssetServiceFactory assetServiceFactory) 21 | { 22 | AssetServiceFactory = assetServiceFactory; 23 | } 24 | 25 | public ICommonEditorAssetServiceFactory AssetServiceFactory { get; } 26 | 27 | public ITagger CreateTagger (ITextBuffer buffer) where T : ITag => 28 | AssetServiceFactory.GetOrCreate (buffer) 29 | .FindAsset ( 30 | (metadata) => metadata.TagTypes.Any (tagType => typeof (T).IsAssignableFrom (tagType)) 31 | ) 32 | ?.CreateTagger (buffer); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Editor/Navigation/MSBuildNavigableSymbol.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | using Microsoft.VisualStudio.Language.Intellisense; 7 | using Microsoft.VisualStudio.Text; 8 | 9 | using MonoDevelop.MSBuild.Language; 10 | 11 | namespace MonoDevelop.MSBuild.Editor.Navigation 12 | { 13 | class MSBuildNavigableSymbol : INavigableSymbol 14 | { 15 | readonly MSBuildNavigationService service; 16 | readonly MSBuildNavigationResult result; 17 | 18 | public MSBuildNavigableSymbol (MSBuildNavigationService service, MSBuildNavigationResult result, ITextSnapshot snapshot) 19 | { 20 | this.service = service; 21 | this.result = result; 22 | SymbolSpan = new SnapshotSpan (snapshot, result.Offset, result.Length); 23 | } 24 | 25 | public SnapshotSpan SymbolSpan { get; } 26 | 27 | public IEnumerable Relationships { get; } = new[] { PredefinedNavigableRelationships.Definition }; 28 | 29 | public void Navigate (INavigableRelationship relationship) 30 | { 31 | service.Navigate (result, SymbolSpan.Snapshot.TextBuffer); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/CodeFixes/AppendNoWarnCodeFixTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System.Threading.Tasks; 7 | 8 | using MonoDevelop.MSBuild.Analyzers; 9 | using MonoDevelop.MSBuild.Editor.CodeFixes; 10 | 11 | using NUnit.Framework; 12 | using NUnit.Framework.Internal; 13 | 14 | namespace MonoDevelop.MSBuild.Tests.Editor.CodeFixes; 15 | 16 | [TestFixture] 17 | class AppendNoWarnCodeFixTests : MSBuildEditorTest 18 | { 19 | [Test] 20 | public Task TestFixAppendNoWarn () 21 | { 22 | return this.TestCodeFix ( 23 | @" 24 | 25 | CS1234;CS456 26 | 27 | 28 | ", 29 | "Prepend '$(NoWarn)' to list", 30 | 1, 31 | @" 32 | 33 | $(NoWarn);CS1234;CS456 34 | 35 | 36 | "); 37 | } 38 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/Completion/TestCompilationProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.ComponentModel.Composition; 5 | 6 | using Microsoft.CodeAnalysis; 7 | using Microsoft.VisualStudio.Composition; 8 | 9 | using MonoDevelop.MSBuild.Editor.Roslyn; 10 | 11 | namespace MonoDevelop.MSBuild.Tests.Editor.Completion 12 | { 13 | [Export (typeof (IRoslynCompilationProvider))] 14 | class TestCompilationProvider : IRoslynCompilationProvider 15 | { 16 | public MetadataReference CreateReference (string assemblyPath) 17 | => MetadataReference.CreateFromFile (assemblyPath); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/Completion/TestSchemaProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable annotations 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.ComponentModel.Composition; 9 | 10 | using Microsoft.VisualStudio.Composition; 11 | 12 | using MonoDevelop.MSBuild.Language.Typesystem; 13 | using MonoDevelop.MSBuild.Schema; 14 | 15 | namespace MonoDevelop.MSBuild.Tests.Editor.Completion 16 | { 17 | [Export (typeof (MSBuildSchemaProvider))] 18 | class TestSchemaProvider : MSBuildSchemaProvider 19 | { 20 | public override MSBuildSchema? GetSchema (string path, string? sdk, out IList? loadErrors) 21 | { 22 | loadErrors = Array.Empty (); 23 | 24 | switch (System.IO.Path.GetFileName(path)) { 25 | case "EagerElementTrigger.csproj": 26 | return new MSBuildSchema { 27 | new PropertyInfo ("Foo", null, valueKind: MSBuildValueKind.Bool) 28 | }; 29 | } 30 | 31 | return base.GetSchema (path, sdk, out loadErrors); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/MSBuildEditorCatalog.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using Microsoft.VisualStudio.MiniEditor; 5 | 6 | using MonoDevelop.MSBuild.Editor.Completion; 7 | using MonoDevelop.Xml.Editor.Tests; 8 | 9 | namespace MonoDevelop.MSBuild.Tests 10 | { 11 | public class MSBuildEditorCatalog : EditorCatalog 12 | { 13 | public MSBuildEditorCatalog (EditorEnvironment.Host host) : base (host) { } 14 | 15 | internal MSBuildParserProvider MSBuildParserProvider => GetService (); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/MSBuildQuickInfoTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | using MonoDevelop.Xml.Editor.Tests.Extensions; 8 | 9 | using NUnit.Framework; 10 | 11 | namespace MonoDevelop.MSBuild.Tests 12 | { 13 | [TestFixture] 14 | public class MSBuildQuickInfoTests : MSBuildEditorTest 15 | { 16 | [Test] 17 | public async Task TestItemGroupQuickInfo () 18 | { 19 | var result = await this.GetQuickInfoItems (""); 20 | Assert.NotNull (result); 21 | Assert.IsTrue (result.Items.Any ()); 22 | } 23 | 24 | [Test] 25 | public async Task TestClosingTag () 26 | { 27 | var result = await this.GetQuickInfoItems (""); 28 | Assert.NotNull (result); 29 | Assert.IsTrue (result.Items.Any ()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/Mocks/TestMSBuildEnvironment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System.ComponentModel.Composition; 7 | 8 | using Microsoft.Extensions.Logging; 9 | 10 | using MonoDevelop.MSBuild.Editor; 11 | using MonoDevelop.MSBuild.SdkResolution; 12 | 13 | namespace MonoDevelop.MSBuild.Tests.Editor.Mocks 14 | { 15 | // Subclass CurrentProcessMSBuildEnvironment so we get real value for ToolsPath, allowing .tasks and .overridetasks to be found by tests 16 | [Export (typeof (IMSBuildEnvironment))] 17 | [method: ImportingConstructor] 18 | class TestMSBuildEnvironment (MSBuildEnvironmentLogger environmentLogger) : CurrentProcessMSBuildEnvironment(environmentLogger.Logger) 19 | { 20 | // However, suppress resolution of Microsoft.NET.SDK so tests don't use the SDK fallback. 21 | // The SDK fallback substantially slows down the tests and is not necessary for the tests, 22 | // and different versions of the SDK may introduce unexpected values from inference. 23 | public override SdkInfo? ResolveSdk (MSBuildSdkReference sdk, string projectFile, string? solutionPath, ILogger logger) => null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/Mocks/TestPackageFeedRegistry.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.ComponentModel.Composition; 7 | using Microsoft.VisualStudio.Utilities; 8 | using ProjectFileTools.NuGetSearch.Contracts; 9 | 10 | namespace MonoDevelop.MSBuild.Tests.Editor.Mocks 11 | { 12 | [Export (typeof (IPackageFeedRegistryProvider))] 13 | [Name ("Test Package Feed Registry Provider")] 14 | internal class TestPackageFeedRegistryProvider : IPackageFeedRegistryProvider 15 | { 16 | public IReadOnlyList ConfiguredFeeds => Array.Empty (); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests.Editor/TestLoggers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System.ComponentModel.Composition; 7 | 8 | using Microsoft.Extensions.Logging; 9 | using Microsoft.VisualStudio.Utilities; 10 | 11 | using MonoDevelop.MSBuild.Editor; 12 | using MonoDevelop.Xml.Editor.Logging; 13 | using MonoDevelop.Xml.Tests; 14 | 15 | namespace MonoDevelop.MSBuild.Tests.Editor; 16 | 17 | [Export (typeof (IEditorLoggerProvider))] 18 | [ContentType (MSBuildContentType.Name)] 19 | class MSBuildTestEditorLoggerProvider : IEditorLoggerProvider 20 | { 21 | public ILogger CreateLogger (string categoryName) => TestLoggerFactory.CreateLogger (categoryName); 22 | 23 | public void Dispose () { } 24 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/Analyzers/AppendNoWarnAnalyzerTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.MSBuild.Analysis; 5 | using MonoDevelop.MSBuild.Analyzers; 6 | 7 | using NUnit.Framework; 8 | 9 | namespace MonoDevelop.MSBuild.Tests.Analyzers 10 | { 11 | [TestFixture] 12 | class AppendNoWarnAnalyzerTest : MSBuildDocumentTest 13 | { 14 | [TestCase("CS123;CS346;CS567", true)] 15 | [TestCase("CS123", true)] 16 | [TestCase("$(NoWarn)CS234", true)] 17 | [TestCase("$(NoWarn);CS123", false)] 18 | [TestCase("CS563; $(NoWarn) ;CS123", false)] 19 | [TestCase(" $(NoWarn) ", false)] 20 | [TestCase("$(NoWarn);", false)] 21 | public void ValueInSimpleProject (string value, bool isError) 22 | { 23 | var source = $@" 24 | 25 | {value} 26 | 27 | "; 28 | 29 | var analyzer = new AppendNoWarnAnalyzer (); 30 | 31 | MSBuildDiagnostic[] expected = isError 32 | ? [new MSBuildDiagnostic (analyzer.SupportedDiagnostics[0], MSBuildDocumentTest.SpanFromLineColLength (source, 3, 6, 6))] 33 | : []; 34 | 35 | MSBuildDocumentTest.VerifyDiagnostics (source, [ analyzer ], ignoreUnexpectedDiagnostics: true, expectedDiagnostics: expected); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/Analyzers/DoNotAssignMSBuildAllProjectsAnalyzerTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.MSBuild.Analysis; 5 | using MonoDevelop.MSBuild.Analyzers; 6 | using NUnit.Framework; 7 | 8 | namespace MonoDevelop.MSBuild.Tests.Analyzers 9 | { 10 | [TestFixture] 11 | class DoNotAssignMSBuildAllProjectsAnalyzerTest : MSBuildDocumentTest 12 | { 13 | [Test] 14 | public void SingleAssign () 15 | { 16 | var source = @" 17 | 18 | Hello 19 | $(MSBuildThisProjectFile);$(MSBuildAllProjects) 20 | 21 | "; 22 | 23 | var analyzer = new DoNotAssignMSBuildAllProjectsAnalyzer (); 24 | 25 | var expected = new MSBuildDiagnostic ( 26 | analyzer.SupportedDiagnostics[0], SpanFromLineColLength (source, 4, 5, 20) 27 | ); 28 | 29 | VerifyDiagnostics (source, analyzer, expected); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/Completion/ExxpressionCompletionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Immutable; 5 | using System.Linq; 6 | 7 | using MonoDevelop.MSBuild.Analysis; 8 | using MonoDevelop.MSBuild.Language; 9 | using MonoDevelop.MSBuild.Language.Typesystem; 10 | using MonoDevelop.MSBuild.Schema; 11 | 12 | using NUnit.Framework; 13 | 14 | namespace MonoDevelop.MSBuild.Tests.Completion; 15 | 16 | [TestFixture] 17 | class ExpressionCompletionTests : MSBuildExpressionCompletionTest 18 | { 19 | [Test] 20 | public void WarningCodes () 21 | { 22 | var source = @" 23 | 24 | | 25 | 26 | "; 27 | 28 | 29 | var schema = new MSBuildSchema () { 30 | new CustomTypeInfo ( 31 | [ 32 | new CustomTypeValue ("CS123", null), 33 | new CustomTypeValue ("CS456", null) 34 | ], 35 | "csharp-warnings", 36 | baseKind: MSBuildValueKind.WarningCode 37 | ), 38 | new PropertyInfo ("NoWarn", "", MSBuildValueKind.WarningCode) 39 | }; 40 | 41 | var completions = GetExpressionCompletion (source, out _, schema: schema).ToArray (); 42 | 43 | Assert.AreEqual (2, completions.Length); 44 | Assert.AreEqual ("CS123", completions[0].Name); 45 | Assert.AreEqual ("CS456", completions[1].Name); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/Helpers/MSBuildDocumentTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.MSBuild.Tests.Helpers; 5 | 6 | namespace MonoDevelop.MSBuild.Tests; 7 | 8 | partial class MSBuildDocumentTest 9 | { 10 | static MSBuildDocumentTest () => MSBuildTestHelpers.RegisterMSBuildAssemblies (); 11 | } 12 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/Helpers/MSBuildTestLogHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace MonoDevelop.MSBuild.Tests; 12 | 13 | public static class MSBuildTestLogHelpers 14 | { 15 | public static ILogger WithFilter (this ILogger logger, IEnumerable ignoreEventNames) 16 | { 17 | return new FilteredLogger (logger, ignoreEventNames); 18 | } 19 | 20 | class FilteredLogger (ILogger inner, IEnumerable ignoreEventNames) : ILogger 21 | { 22 | HashSet ignoredEvents = new HashSet (ignoreEventNames); 23 | 24 | public IDisposable? BeginScope (TState state) where TState : notnull => inner.BeginScope (state); 25 | 26 | public bool IsEnabled (LogLevel logLevel) => inner.IsEnabled (logLevel); 27 | 28 | public void Log (LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) 29 | { 30 | if (eventId.Name is null || !ignoredEvents.Contains (eventId.Name)) { 31 | inner.Log (logLevel, eventId, state, exception, formatter); 32 | } 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/Helpers/TestSchemaProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using MonoDevelop.MSBuild.Schema; 7 | 8 | namespace MonoDevelop.MSBuild.Tests.Helpers 9 | { 10 | class TestSchemaProvider : MSBuildSchemaProvider 11 | { 12 | readonly Dictionary<(string filename, string sdk), MSBuildSchema> schemas = new (); 13 | 14 | public void AddTestSchema (string filename, string sdk, MSBuildSchema schema) 15 | { 16 | schemas.Add ((filename, sdk), schema); 17 | } 18 | 19 | public override MSBuildSchema GetSchema (string path, string sdk, out IList loadErrors) 20 | { 21 | if (schemas.TryGetValue ((Path.GetFileName (path), sdk), out MSBuildSchema schema)) { 22 | loadErrors = null; 23 | return schema; 24 | } 25 | 26 | return base.GetSchema (path, sdk, out loadErrors); 27 | } 28 | 29 | public override ICollection GetFallbackSchemas () => []; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/InternalsVisibleTo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | [assembly: System.Runtime.CompilerServices.InternalsVisibleTo ("MonoDevelop.MSBuild.Tests.Editor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100510a1c03c181816c65be87b8fd908657f57154bfe3304485a0613251255e13b1313f6acbd296bc807779dff01271101cc7c341357a5af16be39072d9ff5b3fbf72c3100aab5b55775b4b5494eb5c93209755fe3b4eb95f64c790bb1bab867217919b365f120d8885769da792a412d903b0a953357b611d71097fdfce4caf62fa")] 5 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/MonoDevelop.MSBuild.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net48;net8.0 5 | 6 | 7 | 8 | 9 | False 10 | False 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/PackageSearch/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | [*.cs] 4 | 5 | # revert settings to match roslyn style better 6 | indent_style = space 7 | trim_trailing_whitespace = false 8 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 9 | csharp_space_between_method_call_name_and_opening_parenthesis = false 10 | csharp_space_after_keywords_in_control_flow_statements = false 11 | 12 | # Newline settings 13 | csharp_new_line_before_open_brace = methods, properties, control_blocks, types 14 | csharp_new_line_before_else = false 15 | csharp_new_line_before_catch = false 16 | csharp_new_line_before_finally = false 17 | 18 | # VS threading analyzer triggers on imported roslyn code 19 | dotnet_diagnostic.VSTHRD002.severity = none 20 | dotnet_diagnostic.VSTHRD003.severity = none 21 | dotnet_diagnostic.VSTHRD103.severity = none 22 | dotnet_diagnostic.VSTHRD110.severity = none -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/PackageSearch/Mocks/MockWebRequestFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using ProjectFileTools.NuGetSearch.IO; 8 | 9 | namespace ProjectFileTools.NuGetSearch.Tests; 10 | 11 | public class MockWebRequestFactory : IWebRequestFactory 12 | { 13 | public Task GetStringAsync(string endpoint, CancellationToken cancellationToken) 14 | { 15 | throw new NotImplementedException(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild.Tests/XmlEscapingTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using NUnit.Framework; 5 | using MonoDevelop.MSBuild.Language; 6 | 7 | namespace MonoDevelop.MSBuild.Tests 8 | { 9 | [TestFixture] 10 | public class XmlEscapingTests 11 | { 12 | [Test] 13 | [TestCase ("abc <> ' def", "abc <> ' def")] 14 | [TestCase ( "&"", "&\"")] 15 | public void Unescape (string escaped, string unescaped) 16 | { 17 | Assert.AreEqual ( 18 | unescaped, 19 | XmlEscaping.UnescapeEntities (escaped) 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Analysis/ElementDiagnosticContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Threading; 5 | 6 | using MonoDevelop.MSBuild.Dom; 7 | using MonoDevelop.MSBuild.Language; 8 | using MonoDevelop.MSBuild.Language.Syntax; 9 | using MonoDevelop.MSBuild.Language.Typesystem; 10 | using MonoDevelop.Xml.Dom; 11 | 12 | namespace MonoDevelop.MSBuild.Analysis 13 | { 14 | public readonly struct ElementDiagnosticContext 15 | { 16 | readonly MSBuildAnalysisSession session; 17 | internal MSBuildDocument Document => session.Document; 18 | public CancellationToken CancellationToken => session.CancellationToken; 19 | 20 | public MSBuildElement Element { get; } 21 | public XElement XElement => Element.XElement; 22 | public MSBuildElementSyntax ElementSyntax => Element.Syntax; 23 | public MSBuildSyntaxKind SyntaxKind => Element.SyntaxKind; 24 | public MSBuildValueKind ValueKind => ElementSyntax.ValueKind; 25 | 26 | internal ElementDiagnosticContext ( 27 | MSBuildAnalysisSession session, 28 | MSBuildElement element) 29 | { 30 | this.session = session; 31 | Element = element; 32 | } 33 | 34 | public void ReportDiagnostic (MSBuildDiagnostic diagnostic) => session.ReportDiagnostic (diagnostic); 35 | } 36 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Analysis/MSBuildAnalyzer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Immutable; 5 | 6 | namespace MonoDevelop.MSBuild.Analysis 7 | { 8 | public abstract class MSBuildAnalyzer 9 | { 10 | public abstract ImmutableArray SupportedDiagnostics { get; } 11 | 12 | public abstract void Initialize (MSBuildAnalysisContext context); 13 | 14 | internal bool Disabled { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Analysis/MSBuildAnalyzerAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | 6 | namespace MonoDevelop.MSBuild.Analysis 7 | { 8 | [AttributeUsage (AttributeTargets.Class, AllowMultiple = false, Inherited = false)] 9 | public class MSBuildAnalyzerAttribute : Attribute 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Analysis/MSBuildDiagnostic.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System.Collections.Immutable; 7 | using MonoDevelop.Xml.Dom; 8 | 9 | namespace MonoDevelop.MSBuild.Analysis 10 | { 11 | public class MSBuildDiagnostic 12 | { 13 | public MSBuildDiagnosticDescriptor Descriptor { get; } 14 | public ImmutableDictionary Properties { get; } 15 | public TextSpan Span { get; } 16 | 17 | readonly object[]? messageArgs; 18 | 19 | public MSBuildDiagnostic (MSBuildDiagnosticDescriptor descriptor, TextSpan span, ImmutableDictionary? properties = null, object[]? messageArgs = null) 20 | { 21 | Descriptor = descriptor; 22 | Span = span; 23 | Properties = properties ?? ImmutableDictionary.Empty; 24 | this.messageArgs = messageArgs; 25 | } 26 | 27 | public MSBuildDiagnostic (MSBuildDiagnosticDescriptor descriptor, TextSpan span, params object [] messageArgs) 28 | : this (descriptor, span, null, messageArgs) 29 | { 30 | } 31 | 32 | public string GetFormattedMessageWithTitle () => Descriptor.GetFormattedMessageAndTitle (messageArgs); 33 | } 34 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Analysis/MSBuildDiagnosticExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Collections.Immutable; 6 | using MonoDevelop.Xml.Dom; 7 | 8 | namespace MonoDevelop.MSBuild.Analysis 9 | { 10 | static class MSBuildDiagnosticExtensions 11 | { 12 | public static void Add ( 13 | this ICollection list, 14 | MSBuildDiagnosticDescriptor descriptor, 15 | TextSpan span 16 | ) 17 | => list.Add (new MSBuildDiagnostic (descriptor, span)); 18 | 19 | public static void Add ( 20 | this ICollection list, 21 | MSBuildDiagnosticDescriptor descriptor, 22 | TextSpan span, 23 | params object[] messageArgs 24 | ) 25 | => list.Add (new MSBuildDiagnostic (descriptor, span, messageArgs)); 26 | 27 | public static void Add (this ICollection list, 28 | MSBuildDiagnosticDescriptor descriptor, 29 | TextSpan span, 30 | ImmutableDictionary properties, 31 | params object[] messageArgs 32 | ) 33 | => list.Add (new MSBuildDiagnostic (descriptor, span, properties, messageArgs)); 34 | } 35 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Analysis/MSBuildDiagnosticSeverity.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | 5 | using System; 6 | 7 | namespace MonoDevelop.MSBuild.Analysis 8 | { 9 | [Flags] 10 | public enum MSBuildDiagnosticSeverity 11 | { 12 | None = 0, 13 | 14 | Suggestion = 1 << 0, 15 | Warning = 1 << 1, 16 | Error = 1 << 2, 17 | 18 | All = Suggestion | Warning | Error 19 | } 20 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Analysis/PropertyWriteDiagnosticContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Threading; 5 | 6 | using MonoDevelop.MSBuild.Dom; 7 | using MonoDevelop.MSBuild.Language; 8 | using MonoDevelop.MSBuild.Language.Expressions; 9 | using MonoDevelop.MSBuild.Language.Typesystem; 10 | using MonoDevelop.Xml.Dom; 11 | 12 | namespace MonoDevelop.MSBuild.Analysis 13 | { 14 | public readonly struct PropertyWriteDiagnosticContext 15 | { 16 | readonly MSBuildAnalysisSession session; 17 | 18 | internal MSBuildDocument Document => session.Document; 19 | public CancellationToken CancellationToken => session.CancellationToken; 20 | 21 | public MSBuildPropertyElement Element { get; } 22 | public XElement XElement => Element.XElement; 23 | public MSBuildValueKind Kind => Element.Syntax.ValueKind; 24 | internal ExpressionNode Node => Element.Value; 25 | 26 | internal PropertyWriteDiagnosticContext ( 27 | MSBuildAnalysisSession session, MSBuildPropertyElement element) 28 | { 29 | this.session = session; 30 | Element = element; 31 | } 32 | 33 | public void ReportDiagnostic (MSBuildDiagnostic diagnostic) => session.ReportDiagnostic (diagnostic); 34 | } 35 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/DisplayText.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild; 5 | 6 | /// 7 | /// Represents text that can be displayed to the user and that may have richer formatting available 8 | /// 9 | public readonly struct DisplayText 10 | { 11 | public DisplayText (string text, object? displayElement = null) 12 | { 13 | Text = text; 14 | DisplayElement = displayElement; 15 | } 16 | 17 | /// 18 | /// An optional formatted display element for tooltip in the editor. If not provided, one will be created from the text. 19 | /// 20 | public object? DisplayElement { get; } 21 | 22 | public string? Text { get; } 23 | public bool IsEmpty => string.IsNullOrEmpty (Text); 24 | 25 | public static implicit operator DisplayText (string? s) => new (s); 26 | } 27 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Dom/MSBuildObject.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #if NETCOREAPP 5 | #nullable enable 6 | #endif 7 | 8 | using MonoDevelop.MSBuild.Language.Expressions; 9 | using MonoDevelop.MSBuild.Language.Syntax; 10 | using MonoDevelop.Xml.Dom; 11 | 12 | namespace MonoDevelop.MSBuild.Dom 13 | { 14 | public abstract class MSBuildObject 15 | { 16 | protected MSBuildObject (MSBuildElement? parent, ExpressionNode? value) 17 | { 18 | Parent = parent; 19 | Value = value; 20 | } 21 | 22 | public abstract MSBuildSyntaxKind SyntaxKind { get; } 23 | public MSBuildElement? Parent { get; private set; } 24 | public ExpressionNode? Value { get; } 25 | 26 | public abstract TextSpan NameSpan { get; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Evaluation/EvaluatedValue.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | using MonoDevelop.MSBuild.Util; 9 | 10 | namespace MonoDevelop.MSBuild.Evaluation 11 | { 12 | /// 13 | /// A value that has been escaped and evaluated 14 | /// 15 | readonly struct EvaluatedValue 16 | { 17 | public string? EscapedValue { get; } 18 | 19 | [MemberNotNullWhen(false, nameof (EscapedValue))] 20 | public readonly bool IsNullOrEmpty => string.IsNullOrEmpty (EscapedValue); 21 | 22 | public EvaluatedValue (string escapedValue) => EscapedValue = escapedValue; 23 | 24 | public static EvaluatedValue FromUnescaped (string? unescapedValue) => unescapedValue is null? new() : new (MSBuildEscaping.EscapeString (unescapedValue)); 25 | public static EvaluatedValue FromNativePath (string? nativePath) => nativePath is null ? new () : new (MSBuildEscaping.ToMSBuildPath (nativePath)); 26 | 27 | public string? ToNativePath () => EscapedValue is null ? null : MSBuildEscaping.UnescapePath (EscapedValue); 28 | public string? Unescape () => EscapedValue is null ? null : MSBuildEscaping.UnescapePath (EscapedValue); 29 | } 30 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Evaluation/IMSBuildEvaluationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace MonoDevelop.MSBuild.Evaluation 9 | { 10 | interface IMSBuildEvaluationContext 11 | { 12 | /// Gets the only or most likely value for the property 13 | bool TryGetProperty (string name, [NotNullWhen (true)] out EvaluatedValue? value); 14 | 15 | /// Gets all defined or permuted values for the property 16 | /// Certain properties are multivalued only at the beginning of a project import 17 | bool TryGetMultivaluedProperty (string name, [NotNullWhen (true)] out OneOrMany? value, bool isProjectImportStart = false); 18 | 19 | ILogger Logger { get; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Evaluation/IMSBuildEvaluator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Evaluation 5 | { 6 | interface IMSBuildEvaluator 7 | { 8 | string Evaluate (string expression); 9 | } 10 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Evaluation/Imported/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | 4 | # Imported code 5 | [*.cs] 6 | indent_style = space 7 | trim_trailing_whitespace = false 8 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 9 | csharp_space_between_method_call_name_and_opening_parenthesis = false 10 | csharp_space_after_keywords_in_control_flow_statements = false 11 | 12 | # Newline settings 13 | csharp_new_line_before_open_brace = methods, properties, control_blocks, types 14 | csharp_new_line_before_else = false 15 | csharp_new_line_before_catch = false 16 | csharp_new_line_before_finally = false -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Evaluation/Imported/IntrinsicFunctions.Override.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | // 4 | // Implementations for methods made partial in the imported class IntrinsicFunctions 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace Microsoft.Build.Evaluation 13 | { 14 | partial class IntrinsicFunctions 15 | { 16 | internal static partial bool DoesTaskHostExist (string runtime, string architecture) => true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/IMSBuildFileSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | using System.Collections.Generic; 6 | using System.IO; 7 | 8 | namespace MonoDevelop.MSBuild 9 | { 10 | interface IMSBuildFileSystem 11 | { 12 | bool DirectoryExists (string basePath); 13 | IEnumerable GetDirectories (string basePath); 14 | IEnumerable GetFiles (string basePath); 15 | } 16 | 17 | class DefaultMSBuildFileSystem : IMSBuildFileSystem 18 | { 19 | DefaultMSBuildFileSystem () 20 | { 21 | } 22 | 23 | public bool DirectoryExists (string path) => Directory.Exists (path); 24 | 25 | public IEnumerable GetDirectories (string path) => Directory.GetDirectories (path); 26 | 27 | public IEnumerable GetFiles (string path) => Directory.GetFiles (path); 28 | 29 | public static DefaultMSBuildFileSystem Instance { get; } = new DefaultMSBuildFileSystem (); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/ITaskMetadataBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using Microsoft.Extensions.Logging; 7 | 8 | using MonoDevelop.MSBuild.Evaluation; 9 | using MonoDevelop.MSBuild.Language.Expressions; 10 | using MonoDevelop.MSBuild.Language.Typesystem; 11 | 12 | namespace MonoDevelop.MSBuild.Schema 13 | { 14 | interface ITaskMetadataBuilder 15 | { 16 | TaskInfo? CreateTaskInfo ( 17 | string typeName, string assemblyName, ExpressionNode assemblyFile, string assemblyFileStr, 18 | string declaredInFile, Xml.Dom.TextSpan? declarationSpan, 19 | IMSBuildEvaluationContext evaluationContext, 20 | ILogger logger); 21 | } 22 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/AnnotationTable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Runtime.CompilerServices; 9 | 10 | namespace MonoDevelop.MSBuild.Language 11 | { 12 | class AnnotationTable where T : class 13 | { 14 | readonly ConditionalWeakTable> annotations = new ConditionalWeakTable> (); 15 | 16 | public U Get (T o) 17 | { 18 | if (!annotations.TryGetValue (o, out List values)) 19 | return default (U); 20 | return values.OfType ().FirstOrDefault (); 21 | } 22 | 23 | public IEnumerable GetMany (T o) 24 | { 25 | if (!annotations.TryGetValue (o, out List values)) 26 | return Array.Empty (); 27 | return values.OfType (); 28 | } 29 | 30 | public void Add (T o, U annotation) 31 | { 32 | if (Equals (annotation, default (T))) 33 | return; 34 | 35 | if (!annotations.TryGetValue (o, out List values)) { 36 | values = new List (); 37 | annotations.Add (o, values); 38 | } 39 | values.Add (annotation); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Annotations.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | 5 | using MonoDevelop.Xml.Dom; 6 | 7 | namespace MonoDevelop.MSBuild.Language 8 | { 9 | interface IRegionAnnotation 10 | { 11 | TextSpan Span { get; } 12 | } 13 | 14 | public class NavigationAnnotation : IRegionAnnotation 15 | { 16 | public NavigationAnnotation (string path, TextSpan span) 17 | { 18 | Path = path; 19 | Span = span; 20 | } 21 | 22 | public TextSpan Span { get; } 23 | public string Path { get; } 24 | public bool IsSdk { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/CoreDiagnosticProperty.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Language 5 | { 6 | /// 7 | /// The names of properties used by various attached to core diagnostics. 8 | /// 9 | public static class CoreDiagnosticProperty 10 | { 11 | /// 12 | /// A potentially misspelled name or value 13 | /// 14 | public const string MisspelledNameOrValue = nameof (MisspelledNameOrValue); 15 | 16 | /// 17 | /// For misspelled metadata, the name of the item 18 | /// 19 | public const string MisspelledMetadataItemName = nameof (MisspelledMetadataItemName); 20 | 21 | /// 22 | /// If a misspelled name has multiple spans to fix, the affected spans 23 | /// 24 | public const string MisspelledNameSpans = nameof (MisspelledNameSpans); 25 | 26 | /// 27 | /// For a potentially misspelled value, the symbol representing the expected type of the value 28 | /// 29 | public const string MisspelledValueExpectedType = nameof (MisspelledValueExpectedType); 30 | 31 | /// 32 | /// The symbol affected by the diagnostic 33 | /// 34 | public const string Symbol = nameof (Symbol); 35 | } 36 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Expressions/ExpressionItem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace MonoDevelop.MSBuild.Language.Expressions 7 | { 8 | [DebuggerDisplay ("Item: {Name} (IsSimple: {IsSimpleItem})")] 9 | public class ExpressionItem : ExpressionNode 10 | { 11 | public ExpressionNode Expression { get; } 12 | 13 | public bool IsSimpleItem => Expression is ExpressionItemName; 14 | public string Name => (Expression as ExpressionItemNode)?.ItemName; 15 | public int? NameOffset => (Expression as ExpressionItemNode)?.ItemNameOffset; 16 | 17 | public ExpressionItem (int offset, int length, ExpressionNode expression) : base (offset, length) 18 | { 19 | Expression = expression; 20 | expression.SetParent (this); 21 | } 22 | 23 | public ExpressionItem (int offset, string name) 24 | : this (offset, name.Length + 3, new ExpressionItemName (offset + 2, name)) 25 | { 26 | } 27 | 28 | public override ExpressionNodeKind NodeKind => ExpressionNodeKind.Item; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Expressions/ExpressionList.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | 7 | namespace MonoDevelop.MSBuild.Language.Expressions 8 | { 9 | [DebuggerDisplay ("ComplexExpression ({Nodes.Count} nodes)")] 10 | public class ConcatExpression : ExpressionNode, IContainerExpression 11 | { 12 | public IReadOnlyList Nodes { get; } 13 | 14 | public ConcatExpression (int offset, int length, params ExpressionNode [] nodes) : base (offset, length) 15 | { 16 | Nodes = nodes; 17 | 18 | foreach (var n in nodes) { 19 | n.SetParent (this); 20 | } 21 | } 22 | 23 | public override ExpressionNodeKind NodeKind => ExpressionNodeKind.Concat; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Expressions/ExpressionOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | 6 | namespace MonoDevelop.MSBuild.Language.Expressions 7 | { 8 | [Flags] 9 | public enum ExpressionOptions 10 | { 11 | None = 0, 12 | Metadata = 1, 13 | Items = 1, 14 | Lists = 1 << 1, 15 | CommaLists = 1 << 2, 16 | ItemsAndMetadata = Items | Metadata, 17 | ItemsMetadataAndLists = Items | Metadata | Lists, 18 | ItemsAndLists = Items | Lists 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Expressions/ExpressionProperty.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace MonoDevelop.MSBuild.Language.Expressions 7 | { 8 | [DebuggerDisplay ("Property: {Name} (IsSimple: {IsSimpleProperty})")] 9 | public class ExpressionProperty : ExpressionNode 10 | { 11 | public ExpressionNode Expression { get; } 12 | 13 | public bool IsSimpleProperty => Expression is ExpressionPropertyName; 14 | public string? Name => (Expression as ExpressionPropertyName)?.Name; 15 | public int? NameOffset => (Expression as ExpressionPropertyName)?.Offset; 16 | 17 | public ExpressionProperty (int offset, int length, ExpressionNode expression) : base (offset, length) 18 | { 19 | Expression = expression; 20 | expression.SetParent (this); 21 | } 22 | 23 | public ExpressionProperty(int offset, string name) 24 | : this (offset, name.Length + 3, new ExpressionPropertyName (offset + 2, name)) 25 | { 26 | } 27 | 28 | public override ExpressionNodeKind NodeKind => ExpressionNodeKind.Property; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Expressions/IContainerExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace MonoDevelop.MSBuild.Language.Expressions 7 | { 8 | /// 9 | /// Implemented by expression nodes that contain an indeterminate list of other expressions. 10 | /// 11 | public interface IContainerExpression 12 | { 13 | IReadOnlyList Nodes { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Expressions/ListExpression.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | 7 | namespace MonoDevelop.MSBuild.Language.Expressions 8 | { 9 | [DebuggerDisplay ("ListExpression ({Nodes.Count} nodes)")] 10 | public class ListExpression : ExpressionNode, IContainerExpression 11 | { 12 | public IReadOnlyList Nodes { get; } 13 | 14 | public char Separator { get; } 15 | 16 | public ListExpression (int offset, int length, char separator, params ExpressionNode[] nodes) : base (offset, length) 17 | { 18 | Nodes = nodes; 19 | Separator = separator; 20 | 21 | foreach (var n in nodes) { 22 | n.SetParent (this); 23 | } 24 | } 25 | 26 | public override ExpressionNodeKind NodeKind => ExpressionNodeKind.List; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/IFunctionTypeProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | #nullable enable 6 | 7 | using System.Collections.Generic; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | 11 | using MonoDevelop.MSBuild.Language.Expressions; 12 | using MonoDevelop.MSBuild.Language.Typesystem; 13 | 14 | namespace MonoDevelop.MSBuild.Language 15 | { 16 | interface IFunctionTypeProvider 17 | { 18 | IEnumerable? GetPropertyFunctionNameCompletions (ExpressionNode triggerExpression); 19 | MSBuildValueKind ResolveType (ExpressionPropertyNode node); 20 | IEnumerable GetItemFunctionNameCompletions (); 21 | IEnumerable GetClassNameCompletions (); 22 | FunctionInfo? GetStaticPropertyFunctionInfo (string className, string name); 23 | FunctionInfo? GetPropertyFunctionInfo (MSBuildValueKind valueKind, string name); 24 | FunctionInfo? GetItemFunctionInfo (string name); 25 | ClassInfo? GetClassInfo (string name); 26 | 27 | //FIXME: this is super broken and needs completely rethinking 28 | ISymbol? GetEnumInfo (string reference); 29 | Task EnsureInitialized (CancellationToken token); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/ISymbol.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | using MonoDevelop.MSBuild.Language.Typesystem; 6 | 7 | namespace MonoDevelop.MSBuild.Language; 8 | 9 | /// 10 | /// Base interface symbols that may be displayed in tooltips or completion 11 | /// 12 | public interface ISymbol 13 | { 14 | string Name { get; } 15 | DisplayText Description { get; } 16 | } 17 | 18 | /// 19 | /// Common interface for symbols that are typed 20 | /// 21 | public interface ITypedSymbol : ISymbol 22 | { 23 | MSBuildValueKind ValueKind { get; } 24 | CustomTypeInfo? CustomType { get; } 25 | } 26 | 27 | /// 28 | /// Common interface for symbols that may have a default value 29 | /// 30 | public interface IHasDefaultValue : ITypedSymbol 31 | { 32 | public string? DefaultValue { get; } 33 | } 34 | 35 | /// 36 | /// Common interface for symbols that may have a help URL 37 | /// 38 | public interface IHasHelpUrl : ISymbol 39 | { 40 | public string? HelpUrl { get; } 41 | } 42 | 43 | /// 44 | /// Common interface for symbols that have been inferred from the project 45 | /// 46 | public interface IInferredSymbol : ISymbol 47 | { 48 | } 49 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/KnownCulture.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.MSBuild.Language.Typesystem; 5 | 6 | namespace MonoDevelop.MSBuild.Language; 7 | 8 | record class KnownCulture(string Name, string DisplayName, int Lcid) 9 | { 10 | // 4096 is the "not found" lcid 11 | public bool HasKnownLcid => Lcid != 4096; 12 | 13 | public ITypedSymbol CreateLcidSymbol () => new ConstantSymbol (Lcid.ToString (), $"The LCID of the {DisplayName} culture", MSBuildValueKind.Lcid); 14 | 15 | public ITypedSymbol CreateCultureSymbol () => new ConstantSymbol (Name, $"The name of the {DisplayName} culture", MSBuildValueKind.Culture); 16 | } 17 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/MSBuildReferenceKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Language; 5 | 6 | enum MSBuildReferenceKind 7 | { 8 | None, 9 | Item, 10 | Property, 11 | Metadata, 12 | Task, 13 | TaskParameter, 14 | Keyword, 15 | Target, 16 | KnownValue, 17 | NuGetID, 18 | TargetFramework, 19 | TargetFrameworkIdentifier, 20 | TargetFrameworkVersion, 21 | TargetFrameworkProfile, 22 | FileOrFolder, 23 | ItemFunction, 24 | PropertyFunction, 25 | StaticPropertyFunction, 26 | ClassName, 27 | Enum, 28 | ConditionFunction 29 | } 30 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Syntax/MSBuildElementName.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Language.Syntax; 5 | 6 | /// 7 | /// Constant string representing all the MSBuild element names 8 | /// to help avoid typos and make intent clearer 9 | /// 10 | public static class MSBuildElementName 11 | { 12 | public const string Choose = "Choose"; 13 | public const string Import = "Import"; 14 | public const string ImportGroup = "ImportGroup"; 15 | public const string ItemDefinition = "ItemDefinition"; 16 | public const string ItemDefinitionGroup = "ItemDefinitionGroup"; 17 | public const string ItemGroup = "ItemGroup"; 18 | public const string OnError = "OnError"; 19 | public const string Otherwise = "Otherwise"; 20 | public const string Output = "Output"; 21 | public const string ParameterGroup = "ParameterGroup"; 22 | public const string Project = "Project"; 23 | public const string ProjectExtensions = "ProjectExtensions"; 24 | public const string PropertyGroup = "PropertyGroup"; 25 | public const string Sdk = "Sdk"; 26 | public const string Target = "Target"; 27 | public const string Task = "Task"; 28 | public const string UsingTask = "UsingTask"; 29 | public const string When = "When"; 30 | } 31 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Syntax/MSBuildSyntax.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | #nullable enable 6 | 7 | using System; 8 | 9 | using MonoDevelop.MSBuild.Language.Typesystem; 10 | 11 | namespace MonoDevelop.MSBuild.Language.Syntax; 12 | 13 | public abstract class MSBuildSyntax : ISymbol, ITypedSymbol, IVersionableSymbol, IHasHelpUrl 14 | { 15 | protected MSBuildSyntax ( 16 | string name, DisplayText description, MSBuildValueKind valueKind = MSBuildValueKind.Unknown, 17 | CustomTypeInfo? customType = null, 18 | SymbolVersionInfo? versionInfo = null, 19 | string? helpUrl = null) 20 | { 21 | Name = name; 22 | Description = description; 23 | VersionInfo = versionInfo; 24 | HelpUrl = helpUrl; 25 | 26 | ValueKind = valueKind; 27 | CustomType = customType; 28 | } 29 | 30 | public string Name { get; } 31 | public DisplayText Description { get; } 32 | 33 | public virtual MSBuildValueKind ValueKind { get; } 34 | public CustomTypeInfo? CustomType { get; } 35 | public SymbolVersionInfo? VersionInfo { get; } 36 | public virtual string? HelpUrl { get; } 37 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/TimeMetrics.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | using System.Threading; 6 | 7 | namespace MonoDevelop.MSBuild.Language; 8 | 9 | class TimeMetrics 10 | { 11 | public int Count; 12 | public TimeSpan Total { get; private set; } 13 | public TimeSpan Max { get; private set; } 14 | public TimeSpan Min { get; private set; } 15 | public TimeSpan Average => TimeSpan.FromTicks (Total.Ticks / Count); 16 | 17 | void LogTimeMetric (TimeSpan timeSpan) 18 | { 19 | Total += timeSpan; 20 | Count++; 21 | if (timeSpan > Max) { 22 | Max = timeSpan; 23 | } 24 | if (timeSpan < Min || Min == TimeSpan.Zero) { 25 | Min = timeSpan; 26 | } 27 | } 28 | 29 | public IDisposable CreateTimer () => new TimeMetricsTimer (this); 30 | 31 | struct TimeMetricsTimer : IDisposable 32 | { 33 | int disposed; 34 | readonly DateTime start; 35 | readonly TimeMetrics parent; 36 | 37 | public TimeMetricsTimer (TimeMetrics parent) 38 | { 39 | this.parent = parent; 40 | start = DateTime.UtcNow; 41 | } 42 | 43 | public void Dispose () 44 | { 45 | if (Interlocked.Exchange (ref disposed, 1) == 0) { 46 | var elapsed = DateTime.UtcNow - start; 47 | parent.LogTimeMetric (elapsed); 48 | 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/BaseSymbol.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | using System; 6 | 7 | namespace MonoDevelop.MSBuild.Language.Typesystem 8 | { 9 | /// 10 | /// Anything in the type system with a name and description 11 | /// 12 | public abstract class BaseSymbol : ISymbol 13 | 14 | { 15 | readonly DisplayText description; 16 | 17 | public string Name { get; } 18 | public virtual DisplayText Description => description; 19 | 20 | protected BaseSymbol (string name, DisplayText description) 21 | { 22 | Name = name ?? throw new ArgumentNullException (nameof (name)); 23 | this.description = description; 24 | } 25 | 26 | public override bool Equals (object obj) 27 | { 28 | return obj is ISymbol other && string.Equals (Name, other.Name, StringComparison.OrdinalIgnoreCase); 29 | } 30 | 31 | public override int GetHashCode () 32 | { 33 | return StringComparer.OrdinalIgnoreCase.GetHashCode (Name); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/ConstantSymbol.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace MonoDevelop.MSBuild.Language.Typesystem 7 | { 8 | /// 9 | /// Describes a constant's name and type (but not its value) 10 | /// 11 | [DebuggerDisplay("ConstantSymbol({Name},nq)")] 12 | public class ConstantSymbol : BaseSymbol, ITypedSymbol 13 | { 14 | public ConstantSymbol (string name, DisplayText description, MSBuildValueKind kind) : base (name, description) 15 | { 16 | this.ValueKind = kind; 17 | } 18 | 19 | public MSBuildValueKind ValueKind { get; } 20 | 21 | public CustomTypeInfo CustomType => null; 22 | } 23 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/CustomTypeValue.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | 8 | namespace MonoDevelop.MSBuild.Language.Typesystem; 9 | 10 | [DebuggerDisplay("CustomTypeValue({Name},nq)")] 11 | public sealed class CustomTypeValue ( 12 | string name, DisplayText description, SymbolVersionInfo? versionInfo = null, string? helpUrl = null, 13 | IReadOnlyList? aliases = null) 14 | : ISymbol, ITypedSymbol, IVersionableSymbol, IHasHelpUrl 15 | { 16 | public CustomTypeInfo CustomType { get; private set; } 17 | 18 | public MSBuildValueKind ValueKind => MSBuildValueKind.CustomType; 19 | 20 | public string Name { get; } = name; 21 | 22 | public DisplayText Description { get; } = description; 23 | 24 | public SymbolVersionInfo? VersionInfo { get; } = versionInfo; 25 | 26 | public string? HelpUrl => helpUrl ?? CustomType?.HelpUrl; 27 | 28 | public IReadOnlyList? Aliases { get; } = aliases; 29 | 30 | internal void SetParent (CustomTypeInfo parent) => CustomType = parent; 31 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/FileOrFolderInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Language.Typesystem 5 | { 6 | public sealed class FileOrFolderInfo : BaseSymbol 7 | { 8 | public bool IsFolder { get; } 9 | 10 | public FileOrFolderInfo (string name, bool isDirectory, DisplayText description) : base (name, description) 11 | { 12 | IsFolder = isDirectory; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/FrameworkInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using NuGet.Frameworks; 7 | 8 | namespace MonoDevelop.MSBuild.Language.Typesystem 9 | { 10 | // this is kinda weird as it can represent a value that's a piece of a framework ID: 11 | // a shortname, identifier, version or profile 12 | // the "name" is the piece that's being represented and the reference is the 13 | // full ID, or as close to it as we have 14 | class FrameworkInfo : BaseSymbol, IVersionableSymbol 15 | { 16 | public FrameworkInfo (string name, NuGetFramework reference, string? deprecationMessage = null) 17 | : base (name, null) 18 | { 19 | Reference = reference; 20 | if (deprecationMessage is not null) { 21 | VersionInfo = SymbolVersionInfo.Deprecated (deprecationMessage); 22 | } 23 | } 24 | 25 | public NuGetFramework Reference { get; } 26 | 27 | public SymbolVersionInfo? VersionInfo { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/FunctionInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace MonoDevelop.MSBuild.Language.Typesystem; 8 | 9 | static class FunctionInfoExtensions 10 | { 11 | /// 12 | /// If there are multiple items that have the same name, collapse them into a single with overloads. 13 | /// 14 | public static ICollection CollapseOverloads (this IEnumerable infos) 15 | { 16 | var functions = new Dictionary (); 17 | foreach (var info in infos) { 18 | if (functions.TryGetValue (info.Name, out FunctionInfo existing)) { 19 | existing.Overloads.Add (info); 20 | } else { 21 | functions.Add (info.Name, info); 22 | } 23 | } 24 | return functions.Values.ToArray (); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/ItemInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | #nullable enable 6 | 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | 10 | namespace MonoDevelop.MSBuild.Language.Typesystem; 11 | 12 | [DebuggerDisplay("ItemInfo({Name},nq)")] 13 | public class ItemInfo ( 14 | string name, DisplayText description, string? includeDescription = null, 15 | MSBuildValueKind valueKind = MSBuildValueKind.Unknown, CustomTypeInfo? customType = null, 16 | Dictionary? metadata = null, 17 | SymbolVersionInfo? versionInfo = null, 18 | string? helpUrl = null) 19 | : VariableInfo(name, description, valueKind, customType, null, versionInfo), IHasHelpUrl 20 | { 21 | public Dictionary Metadata { get; } = metadata ?? new (System.StringComparer.OrdinalIgnoreCase); 22 | 23 | //custom description for the kinds of items in the include 24 | public string? IncludeDescription { get; } = includeDescription; 25 | 26 | public string? HelpUrl { get; } = helpUrl; 27 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/MetadataInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Xamarin Inc. 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | 5 | using System.Diagnostics; 6 | 7 | namespace MonoDevelop.MSBuild.Language.Typesystem; 8 | 9 | [DebuggerDisplay("MetadataInfo({DebuggerName},nq)")] 10 | public class MetadataInfo : VariableInfo, IHasHelpUrl 11 | { 12 | [DebuggerHidden] 13 | string DebuggerName => Item?.Name is string itemName? $"{itemName}.{Name}" : null; 14 | 15 | public bool Reserved { get; } 16 | public bool Required { get; } 17 | 18 | public MetadataInfo ( 19 | string name, DisplayText description, 20 | bool reserved = false, bool required = false, MSBuildValueKind valueKind = MSBuildValueKind.Unknown, 21 | ItemInfo? item = null, CustomTypeInfo? customType = null, 22 | string? defaultValue = null, 23 | SymbolVersionInfo? versionInfo = null, 24 | string? helpUrl = null) 25 | : base (name, description, valueKind, customType, defaultValue, versionInfo) 26 | { 27 | Item = item; 28 | Required = required; 29 | Reserved = reserved; 30 | HelpUrl = helpUrl; 31 | } 32 | 33 | public ItemInfo? Item { get; internal set; } 34 | 35 | public string? HelpUrl { get; } 36 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/TargetInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace MonoDevelop.MSBuild.Language.Typesystem; 7 | 8 | [DebuggerDisplay("TargetInfo({Name},nq)")] 9 | public class TargetInfo ( 10 | string name, DisplayText description, SymbolVersionInfo? versionInfo = null, string? helpUrl = null 11 | ) 12 | : BaseSymbol(name, description), IVersionableSymbol, IHasHelpUrl 13 | { 14 | public SymbolVersionInfo? VersionInfo { get; } = versionInfo; 15 | public string? HelpUrl { get; } = helpUrl; 16 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/Typesystem/ValueKindInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MonoDevelop.MSBuild.Language.Typesystem 8 | { 9 | public class MSBuildTypeInfo 10 | { 11 | public MSBuildValueKind Kind { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Language/WellKnownTaskFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | 6 | namespace MonoDevelop.MSBuild.Language; 7 | 8 | class WellKnownTaskFactory 9 | { 10 | const string RoslynCodeTaskFactoryAssemblyProperty = "$(RoslynCodeTaskFactory)"; 11 | 12 | public const string CodeTaskFactory = "CodeTaskFactory"; 13 | public const string RoslynCodeTaskFactory = "RoslynCodeTaskFactory"; 14 | 15 | public static string? TryGet (string taskFactoryAttributeValue, string? assemblyNameAttributeValue) 16 | { 17 | if (string.IsNullOrEmpty (taskFactoryAttributeValue)) { 18 | throw new ArgumentException ($"'{nameof (taskFactoryAttributeValue)}' cannot be null or empty.", nameof (taskFactoryAttributeValue)); 19 | } 20 | 21 | if (string.Equals (taskFactoryAttributeValue, CodeTaskFactory, StringComparison.OrdinalIgnoreCase)) { 22 | if (string.Equals (assemblyNameAttributeValue, RoslynCodeTaskFactoryAssemblyProperty, StringComparison.OrdinalIgnoreCase)) { 23 | return RoslynCodeTaskFactory; 24 | } 25 | return CodeTaskFactory; 26 | } 27 | 28 | if (string.Equals (taskFactoryAttributeValue, RoslynCodeTaskFactory, StringComparison.OrdinalIgnoreCase)) { 29 | return RoslynCodeTaskFactory; 30 | } 31 | 32 | return null; 33 | } 34 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/NoopTaskMetadataBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.MSBuild.Evaluation; 5 | using MonoDevelop.MSBuild.Language.Expressions; 6 | using MonoDevelop.MSBuild.Schema; 7 | using MonoDevelop.MSBuild.Language.Typesystem; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace MonoDevelop.MSBuild 11 | { 12 | class NoopTaskMetadataBuilder : ITaskMetadataBuilder 13 | { 14 | public TaskInfo CreateTaskInfo ( 15 | string typeName, string assemblyName, ExpressionNode assemblyFile, string assemblyFileStr, 16 | string declaredInFile, Xml.Dom.TextSpan? declarationSpan, IMSBuildEvaluationContext evaluationContext, ILogger logger) 17 | { 18 | return null; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/NullMSBuildEnvironment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | using Microsoft.Extensions.Logging; 10 | 11 | using MonoDevelop.MSBuild.Language; 12 | using MonoDevelop.MSBuild.SdkResolution; 13 | 14 | namespace MonoDevelop.MSBuild 15 | { 16 | class NullMSBuildEnvironment : IMSBuildEnvironment 17 | { 18 | public Version EngineVersion => new(0, 0); 19 | 20 | public string ToolsVersion => MSBuildToolsVersion.Unknown.ToVersionString (); 21 | 22 | public string? ToolsPath => null; 23 | 24 | public IReadOnlyDictionary ToolsetProperties { get; } = new Dictionary (); 25 | 26 | public IReadOnlyDictionary EnvironmentVariables { get; } = new Dictionary (); 27 | 28 | public IReadOnlyDictionary ProjectImportSearchPaths { get; } = new Dictionary (); 29 | 30 | public IList GetRegisteredSdks () => Array.Empty (); 31 | 32 | public SdkInfo? ResolveSdk (MSBuildSdkReference sdk, string projectFile, string? solutionPath, ILogger logger) => null; 33 | } 34 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Options/MSBuildCompletionOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.Xml.Options; 5 | 6 | namespace MonoDevelop.MSBuild.Options; 7 | 8 | class MSBuildCompletionOptions 9 | { 10 | /// 11 | /// Whether completion should show private symbols from files other than the current file. Private symbols are identified by the convention of prefixing them with an underscore. 12 | /// 13 | public static readonly Option ShowPrivateSymbols = new ("msbuild_show_private_symbols", true, false); 14 | } 15 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Options/MSBuildEditorOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.Xml.Options; 5 | 6 | namespace MonoDevelop.MSBuild.Options; 7 | 8 | class MSBuildEditorOptions 9 | { 10 | // this maps to a VS option 11 | /// 12 | /// Whether to replicate the previous line's newline character when inserting a new line. 13 | /// If false, then the file's default newline character should be used. 14 | /// 15 | public static readonly Option ReplicateNewlineCharacter = new ("replicate_newline_character", true, false); 16 | } 17 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | [*.cs] 4 | 5 | # revert settings to match roslyn style better 6 | indent_style = space 7 | trim_trailing_whitespace = false 8 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 9 | csharp_space_between_method_call_name_and_opening_parenthesis = false 10 | csharp_space_after_keywords_in_control_flow_statements = false 11 | 12 | # Newline settings 13 | csharp_new_line_before_open_brace = methods, properties, control_blocks, types 14 | csharp_new_line_before_else = false 15 | csharp_new_line_before_catch = false 16 | csharp_new_line_before_finally = false 17 | 18 | # VS threading analyzer triggers on imported roslyn code 19 | dotnet_diagnostic.VSTHRD002.severity = none 20 | dotnet_diagnostic.VSTHRD003.severity = none 21 | dotnet_diagnostic.VSTHRD103.severity = none 22 | dotnet_diagnostic.VSTHRD110.severity = none -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IDependencyManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace ProjectFileTools.NuGetSearch.Contracts; 7 | 8 | public interface IDependencyManager 9 | { 10 | T GetComponent(); 11 | 12 | IReadOnlyList GetComponents(); 13 | } 14 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageFeed.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProjectFileTools.NuGetSearch.Contracts; 8 | 9 | public interface IPackageFeed 10 | { 11 | string DisplayName { get; } 12 | 13 | Task GetPackageNamesAsync(string prefix, IPackageQueryConfiguration queryConfiguration, CancellationToken cancellationToken); 14 | 15 | Task GetPackageVersionsAsync(string id, IPackageQueryConfiguration queryConfiguration, CancellationToken cancellationToken); 16 | 17 | Task GetPackageInfoAsync(string id, string? version, IPackageQueryConfiguration queryConfiguration, CancellationToken cancellationToken); 18 | } 19 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageFeedFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace ProjectFileTools.NuGetSearch.Contracts; 5 | 6 | public interface IPackageFeedFactory 7 | { 8 | bool TryHandle(string feed, out IPackageFeed instance); 9 | } 10 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageFeedFactorySelector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace ProjectFileTools.NuGetSearch.Contracts; 7 | 8 | public interface IPackageFeedFactorySelector 9 | { 10 | IEnumerable FeedFactories { get; } 11 | 12 | IPackageFeed GetFeed(string source); 13 | } 14 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageFeedRegistryProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace ProjectFileTools.NuGetSearch.Contracts; 7 | 8 | public interface IPackageFeedRegistryProvider 9 | { 10 | IReadOnlyList ConfiguredFeeds { get; } 11 | } 12 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageFeedSearchJob.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace ProjectFileTools.NuGetSearch.Contracts; 8 | 9 | public interface IPackageFeedSearchJob 10 | { 11 | IReadOnlyList RemainingFeeds { get; } 12 | 13 | IReadOnlyList SearchingIn { get; } 14 | 15 | IReadOnlyList Results { get; } 16 | 17 | bool IsCancelled { get; } 18 | 19 | event EventHandler Updated; 20 | 21 | void Cancel(); 22 | } 23 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageFeedSearcher.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Threading.Tasks; 5 | 6 | namespace ProjectFileTools.NuGetSearch.Contracts; 7 | 8 | public interface IPackageFeedSearcher 9 | { 10 | Task SearchPackagesAsync(string prefix, params string[] feeds); 11 | 12 | Task SearchVersionsAsync(string prefix, params string[] feeds); 13 | } 14 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using ProjectFileTools.NuGetSearch.Feeds; 6 | 7 | namespace ProjectFileTools.NuGetSearch.Contracts; 8 | 9 | public interface IPackageInfo 10 | { 11 | string Id { get; } 12 | 13 | string Version { get; } 14 | 15 | string Title { get; } 16 | 17 | string Authors { get; } 18 | 19 | string Summary { get; } 20 | 21 | string Description { get; } 22 | 23 | string LicenseUrl { get; } 24 | 25 | string ProjectUrl { get; } 26 | 27 | string IconUrl { get; } 28 | 29 | string Tags { get; } 30 | 31 | IReadOnlyList PackageTypes { get; } 32 | 33 | FeedKind SourceKind { get; } 34 | } 35 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageNameSearchResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using ProjectFileTools.NuGetSearch.Feeds; 6 | 7 | namespace ProjectFileTools.NuGetSearch.Contracts; 8 | 9 | public interface IPackageNameSearchResult 10 | { 11 | bool Success { get; } 12 | 13 | FeedKind SourceKind { get; } 14 | 15 | IReadOnlyList Names { get; } 16 | } 17 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageQueryConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | namespace ProjectFileTools.NuGetSearch.Contracts; 7 | 8 | public interface IPackageQueryConfiguration 9 | { 10 | string? CompatibilityTarget { get; } 11 | 12 | bool IncludePreRelease { get; } 13 | 14 | int MaxResults { get; } 15 | 16 | PackageType? PackageType { get; } 17 | } 18 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageSearchManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using ProjectFileTools.NuGetSearch.Feeds; 8 | 9 | namespace ProjectFileTools.NuGetSearch.Contracts; 10 | 11 | public interface IPackageSearchManager 12 | { 13 | IPackageFeedSearchJob> SearchPackageNames(string prefix, string? tfm, string? packageType = null); 14 | 15 | IPackageFeedSearchJob> SearchPackageVersions(string packageName, string? tfm, string? packageType = null); 16 | 17 | IPackageFeedSearchJob SearchPackageInfo(string packageId, string? version, string? tfm); 18 | } 19 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Contracts/IPackageVersionSearchResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using ProjectFileTools.NuGetSearch.Feeds; 6 | 7 | namespace ProjectFileTools.NuGetSearch.Contracts; 8 | 9 | public interface IPackageVersionSearchResult 10 | { 11 | bool Success { get; } 12 | 13 | IReadOnlyList Versions { get; } 14 | 15 | FeedKind SourceKind { get; } 16 | } 17 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Feeds/Disk/NuGetPackageMatcher.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Linq; 5 | 6 | using ProjectFileTools.NuGetSearch.Contracts; 7 | using ProjectFileTools.NuGetSearch.IO; 8 | 9 | namespace ProjectFileTools.NuGetSearch.Feeds.Disk; 10 | 11 | internal static class NuGetPackageMatcher 12 | { 13 | public static bool IsMatch(string dir, IPackageInfo info, IPackageQueryConfiguration queryConfiguration, IFileSystem fileSystem) 14 | { 15 | if (!queryConfiguration.IncludePreRelease) 16 | { 17 | SemanticVersion ver = SemanticVersion.Parse(info.Version); 18 | 19 | if(!string.IsNullOrEmpty(ver?.PrereleaseVersion)) 20 | { 21 | return false; 22 | } 23 | } 24 | 25 | if (queryConfiguration.PackageType != null) 26 | { 27 | //NOTE: can't find any info on how the version is supposed to be handled (or what it's even for), so use an exact match 28 | if (!info.PackageTypes.Any(p => queryConfiguration.PackageType.Equals(p))) 29 | { 30 | return false; 31 | } 32 | } 33 | 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Feeds/FeedKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace ProjectFileTools.NuGetSearch.Feeds; 5 | 6 | public enum FeedKind 7 | { 8 | NuGet, 9 | MyGet, 10 | Local 11 | } 12 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Feeds/PackageFeedFactoryBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Concurrent; 5 | using ProjectFileTools.NuGetSearch.Contracts; 6 | 7 | namespace ProjectFileTools.NuGetSearch.Feeds; 8 | 9 | internal abstract class PackageFeedFactoryBase : IPackageFeedFactory 10 | { 11 | private static readonly ConcurrentDictionary Instances = new ConcurrentDictionary(); 12 | 13 | protected abstract bool CanHandle(string feed); 14 | 15 | protected abstract IPackageFeed Create(string feed); 16 | 17 | public virtual bool TryHandle(string feed, out IPackageFeed instance) 18 | { 19 | if (!CanHandle(feed)) 20 | { 21 | instance = null; 22 | return false; 23 | } 24 | 25 | instance = Instances.GetOrAdd(feed, Create); 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/IO/IFileSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.IO; 6 | 7 | namespace ProjectFileTools.NuGetSearch.IO; 8 | 9 | public interface IFileSystem 10 | { 11 | IEnumerable EnumerateFiles(string path, string pattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly); 12 | 13 | IEnumerable EnumerateDirectories(string path, string pattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly); 14 | 15 | string ReadAllText(string path); 16 | 17 | bool DirectoryExists(string path); 18 | 19 | bool FileExists(string path); 20 | 21 | string GetDirectoryName(string path); 22 | 23 | string GetDirectoryNameOnly(string path); 24 | } 25 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/IO/IWebRequestFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProjectFileTools.NuGetSearch.IO; 8 | 9 | public interface IWebRequestFactory 10 | { 11 | Task GetStringAsync(string endpoint, CancellationToken cancellationToken); 12 | } 13 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/IO/WebRequestFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Net.Http; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace ProjectFileTools.NuGetSearch.IO; 9 | 10 | public class WebRequestFactory : IWebRequestFactory 11 | { 12 | private static readonly HttpClient _httpClient = new HttpClient(); 13 | public async Task GetStringAsync(string endpoint, CancellationToken cancellationToken) 14 | { 15 | try 16 | { 17 | HttpResponseMessage responseMessage = await _httpClient.GetAsync(endpoint, cancellationToken).ConfigureAwait(false); 18 | if (responseMessage.StatusCode == System.Net.HttpStatusCode.NotFound) 19 | { 20 | // avoid a first-chance exception on 404 21 | return null; 22 | } 23 | 24 | responseMessage.EnsureSuccessStatusCode(); 25 | return await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); 26 | } 27 | catch 28 | { 29 | return null; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/IO/WebRequestFactoryExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Newtonsoft.Json.Linq; 7 | 8 | namespace ProjectFileTools.NuGetSearch.IO; 9 | 10 | public static class WebRequestFactoryExtensions 11 | { 12 | public static async Task GetJsonAsync(this IWebRequestFactory factory, string endpoint, CancellationToken cancellationToken) 13 | { 14 | string result = await factory.GetStringAsync(endpoint, cancellationToken).ConfigureAwait(false); 15 | 16 | if(result == null) 17 | { 18 | return null; 19 | } 20 | 21 | try 22 | { 23 | return JToken.Parse(result); 24 | } 25 | catch 26 | { 27 | return null; 28 | } 29 | } 30 | 31 | public static async Task GetDeserializedJsonAsync(this IWebRequestFactory factory, string endpoint, CancellationToken cancellationToken) 32 | { 33 | JToken token = await factory.GetJsonAsync(endpoint, cancellationToken).ConfigureAwait(false); 34 | 35 | if(token == null) 36 | { 37 | return default(T); 38 | } 39 | 40 | return token.ToObject(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Search/PackageNameSearchResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | using ProjectFileTools.NuGetSearch.Contracts; 7 | using ProjectFileTools.NuGetSearch.Feeds; 8 | 9 | namespace ProjectFileTools.NuGetSearch.Search; 10 | 11 | internal class PackageNameSearchResult : IPackageNameSearchResult 12 | { 13 | public static IPackageNameSearchResult Cancelled { get; } = new PackageNameSearchResult(); 14 | 15 | public static IPackageNameSearchResult Failure { get; } = new PackageNameSearchResult(); 16 | 17 | public static Task CancelledTask { get; } = Task.FromResult(Cancelled); 18 | 19 | public static Task FailureTask { get; } = Task.FromResult(Failure); 20 | 21 | public bool Success { get; } 22 | 23 | public IReadOnlyList Names { get; } 24 | 25 | public FeedKind SourceKind { get; } 26 | 27 | private PackageNameSearchResult() 28 | { 29 | } 30 | 31 | public PackageNameSearchResult(IReadOnlyList names, FeedKind sourceKind) 32 | { 33 | Success = true; 34 | Names = names; 35 | SourceKind = sourceKind; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/PackageSearch/Search/PackageVersionSearchResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c).NET Foundation and Contributors 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | using ProjectFileTools.NuGetSearch.Contracts; 7 | using ProjectFileTools.NuGetSearch.Feeds; 8 | 9 | namespace ProjectFileTools.NuGetSearch.Search; 10 | 11 | internal class PackageVersionSearchResult : IPackageVersionSearchResult 12 | { 13 | public static IPackageVersionSearchResult Cancelled { get; } = new PackageVersionSearchResult(); 14 | 15 | public static Task CancelledTask { get; } = Task.FromResult(Cancelled); 16 | 17 | public static IPackageVersionSearchResult Failure { get; } = new PackageVersionSearchResult(); 18 | 19 | public static Task FailureTask { get; } = Task.FromResult(Failure); 20 | 21 | public bool Success { get; } 22 | 23 | public IReadOnlyList Versions { get; } 24 | 25 | public FeedKind SourceKind { get; } 26 | 27 | private PackageVersionSearchResult() 28 | { 29 | } 30 | 31 | public PackageVersionSearchResult(IReadOnlyList versions, FeedKind kind) 32 | { 33 | Versions = versions; 34 | Success = true; 35 | SourceKind = kind; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schema/BuiltInSchemaId.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace MonoDevelop.MSBuild.Schema; 5 | 6 | enum BuiltInSchemaId 7 | { 8 | Android, 9 | Appx, 10 | AspNetCore, 11 | CodeAnalysis, 12 | CommonTargets, 13 | Cpp, 14 | CSharp, 15 | CSharpWarningCodes, 16 | AnalyzerWarningCodes, 17 | StyleRuleCodes, 18 | ILLink, 19 | JavaScript, 20 | NetSdk, 21 | NuGet, 22 | NuGetPack, 23 | GrpcProtobuf, 24 | RazorSdk, 25 | Roslyn, 26 | VisualBasic, 27 | WindowsDesktop, 28 | ProjectSystemMps, 29 | ProjectSystemCps, 30 | GenerateAssemblyInfo, 31 | ValidatePackage, 32 | ILCompiler, 33 | AspireAppHost, 34 | AspireHostingOrchestration, 35 | AspireHostingSdk, 36 | AspireDashboardSdk 37 | } 38 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schema/IMSBuildSchema.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | using MonoDevelop.MSBuild.Language.Typesystem; 7 | 8 | namespace MonoDevelop.MSBuild.Schema 9 | { 10 | interface IMSBuildSchema 11 | { 12 | Dictionary Properties { get; } 13 | Dictionary Items { get; } 14 | Dictionary Tasks { get; } 15 | Dictionary Targets { get; } 16 | Dictionary Types { get; } 17 | 18 | bool IsPrivate (string name); 19 | } 20 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schema/MSBuildSchemaLoadError.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.Xml.Analysis; 5 | 6 | namespace MonoDevelop.MSBuild.Schema; 7 | 8 | public class MSBuildSchemaLoadError 9 | { 10 | public MSBuildSchemaLoadError (string message, XmlDiagnosticSeverity severity, string origin, (int line, int col)? position, string path) 11 | { 12 | Message = message; 13 | JsonPath = path; 14 | FilePosition = position; 15 | Severity = severity; 16 | Origin = origin; 17 | } 18 | 19 | public string Message { get; } 20 | public string JsonPath { get; } 21 | public (int line, int col)? FilePosition { get; } 22 | public XmlDiagnosticSeverity Severity { get; } 23 | 24 | /// 25 | /// Label describing the file or resource in which the error was located 26 | /// 27 | public string Origin { get; } 28 | 29 | public override string ToString () 30 | { 31 | return $"{JsonPath}: {Message}"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schemas/AspireDashboardSdk.buildschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.", 3 | "properties": { 4 | "AspireDashboardDir": { 5 | "description": "The directory where the .NET Aspire Dashboard is located", 6 | "type": "folder-with-slash" 7 | }, 8 | "AspireDashboardPath": { 9 | "description": "The path to the .NET Aspire Dashboard binary", 10 | "type": "file" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schemas/AspireHostingOrchestration.buildschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.", 3 | "properties": { 4 | "DcpDir": { 5 | "description": "The path to the directory containing the DCP tools.", 6 | "type": "folder-with-slash" 7 | }, 8 | "DcpExtensionsDir": { 9 | "description": "The path to the directory containing the DCP tool extensions.", 10 | "type": "folder-with-slash" 11 | }, 12 | "DcpBinDir": { 13 | "description": "The path to the directory containing the DCP tool extension binaries.", 14 | "type": "folder-with-slash" 15 | }, 16 | "DcpCliPath": { 17 | "description": "The path to the DCP CLI executable.", 18 | "type": "file" 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schemas/AspireHostingSdk.buildschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.", 3 | "types": { 4 | "aspire-hosting-sdk-warning": { 5 | "baseType": "warning-code", 6 | "values": { 7 | "ASPIRE002": "Aspire AppHost project has missing dependencies", 8 | "ASPIRE003": "Visual Studio version is too old for Aspire AppHost project" 9 | } 10 | } 11 | }, 12 | "metadata": [ 13 | { 14 | "$appliesTo": [ "ProjectReference" ], 15 | "IsAspireProjectResource":{ 16 | "type": "bool", 17 | "description": "Indicates that the referenced project should be orchestrated by the .NET Aspire AppHost, instead of referencing its output assembly.", 18 | "defaultValue": "true" 19 | } 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schemas/GrpcProtobuf.buildschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.", 3 | "properties": { 4 | "DisableProtobufDesignTimeBuild": { 5 | "description": "Indicates whether Design Time Build should be disabled for referenced @(Protobuf) files.", 6 | "type": "bool" 7 | }, 8 | }, 9 | "items": { 10 | }, 11 | "types": { 12 | } 13 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Schemas/VisualBasic.buildschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.", 3 | "items": { 4 | }, 5 | "properties": { 6 | "DefineDebug": { 7 | "description": "Whether DEBUG is defined", 8 | "type": "bool" 9 | }, 10 | "DefineTrace": { 11 | "description": "Whether TRACE is defined", 12 | "type": "bool" 13 | }, 14 | "OptionCompare": { 15 | "description": "Compare setting", 16 | "type": [ 17 | "Text", 18 | "Binary" 19 | ] 20 | }, 21 | "OptionExplicit": { 22 | "description": "Option Explicit setting", 23 | "type": { "$ref": "#/types/onOff" } 24 | }, 25 | "OptionStrict": { 26 | "description": "Option Strict setting", 27 | "type": { "$ref": "#/types/onOff" } 28 | }, 29 | "OptionInfer": { 30 | "description": "Option Infer setting", 31 | "type": { "$ref": "#/types/onOff" } 32 | }, 33 | "VBRuntime": "", 34 | "MyType": "" 35 | }, 36 | "types": { 37 | "onOff": [ "On", "Off" ] 38 | } 39 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/SdkResolution/Imported/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | 4 | # Imported code 5 | [*.cs] 6 | indent_style = space 7 | trim_trailing_whitespace = false 8 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 9 | csharp_space_between_method_call_name_and_opening_parenthesis = false 10 | csharp_space_after_keywords_in_control_flow_statements = false 11 | 12 | # Newline settings 13 | csharp_new_line_before_open_brace = methods, properties, control_blocks, types 14 | csharp_new_line_before_else = false 15 | csharp_new_line_before_catch = false 16 | csharp_new_line_before_finally = false -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/SdkResolution/MSBuildSdkResolver.SdkResolverContextImpl.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using Microsoft.Build.Framework; 8 | 9 | // this is originally from MonoDevelop - MonoDevelop.Projects.MSBuild.MSBuildSdkResolver 10 | namespace MonoDevelop.MSBuild.SdkResolution 11 | { 12 | partial class MSBuildSdkResolver 13 | { 14 | sealed class SdkResolverContextImpl : SdkResolverContext 15 | { 16 | public SdkResolverContextImpl (SdkLogger logger, string projectFilePath, string? solutionPath, Version msbuildVersion) 17 | { 18 | Logger = logger; 19 | ProjectFilePath = projectFilePath; 20 | SolutionFilePath = solutionPath; 21 | MSBuildVersion = msbuildVersion; 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Util/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Immutable; 5 | 6 | namespace MonoDevelop.MSBuild 7 | { 8 | static class CollectionExtensions 9 | { 10 | public static ImmutableDictionary AddIfNotNull (this ImmutableDictionary dictionary, TKey key, TValue value) 11 | where TValue : class 12 | => value is null? dictionary : dictionary.Add (key, value); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuild/Util/XmlEscaping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace MonoDevelop.MSBuild.Language 8 | { 9 | // TODO: move this to MonoDevelop.Xml 10 | class XmlEscaping 11 | { 12 | static readonly Dictionary entities = new Dictionary { 13 | { "lt", '<' }, 14 | { "gt", '>' }, 15 | { "amp", '&' }, 16 | { "quot", '"' }, 17 | { "apos", '\'' } 18 | }; 19 | 20 | public static string UnescapeEntities (string xmlString) 21 | { 22 | if (xmlString.IndexOf (';') < 0) { 23 | return xmlString; 24 | } 25 | 26 | var sb = new StringBuilder (xmlString.Length); 27 | for (int i = 0; i < xmlString.Length; i++) { 28 | char c = xmlString [i]; 29 | if (c == '&') { 30 | var end = xmlString.IndexOf (';', i + 1); 31 | if (end > -1) { 32 | var s = xmlString.Substring (i + 1, end - i - 1); 33 | if (entities.TryGetValue (s, out char conv)) { 34 | sb.Append (conv); 35 | i = end; 36 | continue; 37 | } 38 | } 39 | } 40 | sb.Append (c); 41 | } 42 | return sb.ToString (); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuildEditor/MSBuildCommands.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.Components.Commands; 5 | using MonoDevelop.Core; 6 | 7 | namespace MonoDevelop.MSBuildEditor 8 | { 9 | public enum MSBuildCommands 10 | { 11 | ToggleShowPrivateSymbols 12 | } 13 | 14 | sealed class ToggleShowPrivateSymbolsHandler : CommandHandler 15 | { 16 | protected override void Update (CommandInfo info) 17 | { 18 | if (MSBuildOptions.ShowPrivateSymbols.Value) { 19 | info.Text = "Hide Private MSBuild Symbols"; 20 | } else { 21 | info.Text = "Hide Private MSBuild Symbols"; 22 | } 23 | } 24 | 25 | protected override void Run () 26 | { 27 | MSBuildOptions.ShowPrivateSymbols.Value = !MSBuildOptions.ShowPrivateSymbols.Value; 28 | } 29 | } 30 | 31 | static class MSBuildOptions 32 | { 33 | static public ConfigurationProperty ShowPrivateSymbols { get; } 34 | = ConfigurationProperty.Create ("MSBuildEditor.ShowPrivateSymbols", false); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuildEditor/Pads/MSBuildImportNavigatorPad.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using MonoDevelop.Components; 5 | using MonoDevelop.Ide.Gui; 6 | 7 | namespace MonoDevelop.MSBuildEditor.Pads 8 | { 9 | class MSBuildImportNavigatorPad : PadContent 10 | { 11 | Control control; 12 | 13 | public override Control Control => control; 14 | 15 | protected override void Initialize (IPadWindow window) 16 | { 17 | base.Initialize (window); 18 | control = new XwtControl (new MSBuildImportNavigator ()); 19 | } 20 | 21 | public override void Dispose () 22 | { 23 | base.Dispose (); 24 | control.Dispose (); 25 | control = null; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /MonoDevelop.MSBuildEditor/Properties/AddinInfo.cs: -------------------------------------------------------------------------------- 1 | using Mono.Addins; 2 | using Mono.Addins.Description; 3 | 4 | [assembly: Addin ( 5 | "MSBuildEditor", 6 | Namespace = "MonoDevelop", 7 | Version = ThisAssembly.AssemblyFileVersion 8 | )] 9 | 10 | [assembly: AddinName ("MSBuild Editor")] 11 | [assembly: AddinCategory ("IDE extensions")] 12 | [assembly: AddinDescription ("Editing support for MSBuild files")] 13 | [assembly: AddinAuthor ("Mikayla Hutchinson")] 14 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuildEditor/Templates/Project.xft.xml: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /MonoDevelop.MSBuildEditor/Templates/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /NoVSEditor.slnf: -------------------------------------------------------------------------------- 1 | { 2 | "solution": { 3 | "path": "MonoDevelop.MSBuildEditor.sln", 4 | "projects": [ 5 | "MSBuildLanguageServer.Tests\\MSBuildLanguageServer.Tests.csproj", 6 | "MSBuildLanguageServer\\MSBuildLanguageServer.csproj", 7 | "MonoDevelop.MSBuild.Editor.Common\\MonoDevelop.MSBuild.Editor.Common.csproj", 8 | "MonoDevelop.MSBuild.Tests\\MonoDevelop.MSBuild.Tests.csproj", 9 | "MonoDevelop.MSBuild\\MonoDevelop.MSBuild.csproj", 10 | "MonoDevelop.Xml\\Core.Tests\\MonoDevelop.Xml.Core.Tests.csproj", 11 | "MonoDevelop.Xml\\Core\\MonoDevelop.Xml.Core.csproj", 12 | "XsdSchemaImporter\\XsdSchemaImporter.csproj" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /XsdSchemaImporter/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # new code, no spaces before parens 4 | [*.cs] 5 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 6 | csharp_space_between_method_call_name_and_opening_parenthesis = false 7 | -------------------------------------------------------------------------------- /XsdSchemaImporter/ConstrainedXmlResolver.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace SchemaImporter; 4 | 5 | /// 6 | /// XmlResolver that resolves only from a fixed (optionally remapped) list 7 | /// 8 | class ConstrainedXmlResolver : System.Xml.XmlResolver, IEnumerable 9 | { 10 | readonly Action logBlockedUri; 11 | readonly Dictionary uriMap = new(); 12 | readonly Func loadUri; 13 | 14 | public ConstrainedXmlResolver(Func loadUri, Action logBlockedUri) 15 | { 16 | this.loadUri = loadUri; 17 | this.logBlockedUri = logBlockedUri; 18 | } 19 | 20 | public override object? GetEntity(Uri absoluteUri, string? role, Type? ofObjectToReturn) 21 | { 22 | if (!uriMap.TryGetValue(absoluteUri, out var remapped)) { 23 | logBlockedUri(absoluteUri); 24 | return null; 25 | } 26 | 27 | return loadUri(remapped); 28 | } 29 | 30 | public IEnumerator GetEnumerator() => uriMap.Keys.GetEnumerator(); 31 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 32 | 33 | public void Add (string uriString) 34 | { 35 | var uri = new Uri(uriString); 36 | uriMap.Add(uri, uri); 37 | } 38 | 39 | public void Add(string uriString, string remappedUriString) 40 | { 41 | var uri = new Uri(uriString); 42 | var remappedUri = new Uri(remappedUriString); 43 | uriMap.Add(uri, remappedUri); 44 | } 45 | } -------------------------------------------------------------------------------- /XsdSchemaImporter/XElementExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | 3 | namespace SchemaImporter 4 | { 5 | static class XElementExtensions 6 | { 7 | static XNamespace nsXsd = XNamespace.Get("http://www.w3.org/2001/XMLSchema"); 8 | 9 | public static void LogUnexpected(this XNode n) => Console.WriteLine($"Unexpected node {n}"); 10 | 11 | public static IEnumerable XsdElements(this XElement el) 12 | { 13 | foreach (var child in el.Elements()) { 14 | if (child.Name.Namespace == nsXsd) { 15 | yield return child; 16 | continue; 17 | } 18 | LogUnexpected(child); 19 | } 20 | yield return el; 21 | } 22 | 23 | public static IEnumerable XsdElements(this XElement el, string name) 24 | { 25 | foreach (var child in el.Elements()) { 26 | if (child.Name.Namespace == nsXsd && child.Name.LocalName == name) { 27 | yield return child; 28 | continue; 29 | } 30 | LogUnexpected(child); 31 | } 32 | yield return el; 33 | } 34 | 35 | public static XElement? XsdSingleElement(this XElement el, string name) 36 | { 37 | XElement? single = null; 38 | foreach (var child in el.Elements()) { 39 | if (single is null && child.Name.Namespace == nsXsd && child.Name.LocalName == name) { 40 | single = child; 41 | continue; 42 | } 43 | LogUnexpected(child); 44 | } 45 | return single; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /XsdSchemaImporter/XsdSchemaImporter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /art/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/art/icon-128.png -------------------------------------------------------------------------------- /art/icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/art/icon-32.png -------------------------------------------------------------------------------- /art/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/art/icon.png -------------------------------------------------------------------------------- /images/completion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/completion.gif -------------------------------------------------------------------------------- /images/condition-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/condition-completion.png -------------------------------------------------------------------------------- /images/find-references.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/find-references.png -------------------------------------------------------------------------------- /images/import-tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/import-tooltip.png -------------------------------------------------------------------------------- /images/property-function-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/property-function-completion.png -------------------------------------------------------------------------------- /images/tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/tooltip.png -------------------------------------------------------------------------------- /images/validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/validation.png -------------------------------------------------------------------------------- /images/vs-code-fixes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-code-fixes.png -------------------------------------------------------------------------------- /images/vs-condition-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-condition-completion.png -------------------------------------------------------------------------------- /images/vs-expression-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-expression-completion.png -------------------------------------------------------------------------------- /images/vs-find-references-cropped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-find-references-cropped.png -------------------------------------------------------------------------------- /images/vs-find-references.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-find-references.png -------------------------------------------------------------------------------- /images/vs-packageref-completion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-packageref-completion.gif -------------------------------------------------------------------------------- /images/vs-quick-info-cropped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-quick-info-cropped.png -------------------------------------------------------------------------------- /images/vs-quick-info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-quick-info.png -------------------------------------------------------------------------------- /images/vs-schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-schema.png -------------------------------------------------------------------------------- /images/vs-validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/images/vs-validation.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # Typescript files 4 | [*.ts] 5 | indent_style = tab 6 | indent_size = 4 7 | 8 | # Preserve formatting of files from extension template for now 9 | [tsconfig.json, webpack.config.json] 10 | indent_style = tab -------------------------------------------------------------------------------- /msbuild-editor-vscode/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": [ 13 | "warn", 14 | { 15 | "selector": "import", 16 | "format": [ "camelCase", "PascalCase" ] 17 | } 18 | ], 19 | "@typescript-eslint/semi": "warn", 20 | "curly": "warn", 21 | "eqeqeq": "warn", 22 | "no-throw-literal": "warn", 23 | "semi": "off" 24 | }, 25 | "ignorePatterns": [ 26 | "out", 27 | "dist", 28 | "**/*.d.ts" 29 | ] 30 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/.vscode-test.mjs: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '@vscode/test-cli'; 2 | 3 | export default defineConfig({ 4 | files: 'out/test/**/*.test.js', 5 | }); 6 | -------------------------------------------------------------------------------- /msbuild-editor-vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/** 4 | node_modules/** 5 | src/** 6 | .gitignore 7 | .yarnrc 8 | **/tsconfig.json 9 | **/.eslintrc.json 10 | **/*.map 11 | **/*.ts 12 | **/.vscode-test.* 13 | 14 | # the images for the README.md are in this directory so the paths 15 | # are correct when the README.md is viewed in the repo. however, they 16 | # are not needed in the vsix as README.md in the generated package 17 | # has the paths rewritten to https URLs to the GitHub repo 18 | images/** 19 | -------------------------------------------------------------------------------- /msbuild-editor-vscode/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "msbuild-editor" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release -------------------------------------------------------------------------------- /msbuild-editor-vscode/esbuild.js: -------------------------------------------------------------------------------- 1 | const esbuild = require("esbuild"); 2 | 3 | const production = process.argv.includes('--production'); 4 | const watch = process.argv.includes('--watch'); 5 | 6 | /** 7 | * @type {import('esbuild').Plugin} 8 | */ 9 | const esbuildProblemMatcherPlugin = { 10 | name: 'esbuild-problem-matcher', 11 | 12 | setup(build) { 13 | build.onStart(() => { 14 | console.log('[watch] build started'); 15 | }); 16 | build.onEnd((result) => { 17 | result.errors.forEach(({ text, location }) => { 18 | console.error(`✘ [ERROR] ${text}`); 19 | console.error(` ${location.file}:${location.line}:${location.column}:`); 20 | }); 21 | console.log('[watch] build finished'); 22 | }); 23 | }, 24 | }; 25 | 26 | async function main() { 27 | const ctx = await esbuild.context({ 28 | entryPoints: [ 29 | 'src/extension.ts' 30 | ], 31 | bundle: true, 32 | format: 'cjs', 33 | minify: production, 34 | sourcemap: !production, 35 | sourcesContent: false, 36 | platform: 'node', 37 | outfile: 'dist/extension.js', 38 | external: ['vscode'], 39 | logLevel: 'silent', 40 | plugins: [ 41 | /* add to the end of plugins array */ 42 | esbuildProblemMatcherPlugin, 43 | ], 44 | }); 45 | if (watch) { 46 | await ctx.watch(); 47 | } else { 48 | await ctx.rebuild(); 49 | await ctx.dispose(); 50 | } 51 | } 52 | 53 | main().catch(e => { 54 | console.error(e); 55 | process.exit(1); 56 | }); 57 | -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-code-fix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-code-fix.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-condition-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-condition-completion.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-expression-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-expression-completion.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-find-references.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-find-references.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-nowarn-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-nowarn-completion.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-packageref-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-packageref-completion.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-quick-info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-quick-info.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-schema.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/images/vscode-validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/msbuild-editor-vscode/images/vscode-validation.png -------------------------------------------------------------------------------- /msbuild-editor-vscode/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "blockComment": [ "" ] 4 | }, 5 | // symbols used as brackets 6 | "brackets": [ 7 | ["<", ">"], 8 | ["[", "]"], 9 | ["(", ")"], 10 | ["$(", ")"], 11 | ["@(", ")"], 12 | ["%(", ")"] 13 | ], 14 | // symbols that are auto closed when typing 15 | "autoClosingPairs": [ 16 | ["<", ">"], 17 | ["[", "]"], 18 | ["(", ")"], 19 | ["\"", "\""], 20 | ["'", "'"], 21 | ["$(", ")"], 22 | ["@(", ")"], 23 | ["%(", ")"] 24 | ], 25 | // symbols that can be used to surround a selection 26 | "surroundingPairs": [ 27 | ["(", ")"], 28 | ["\"", "\""], 29 | ["'", "'"] 30 | ] 31 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/package.nls.json: -------------------------------------------------------------------------------- 1 | { 2 | "command.msbuild.reportIssue": "Report an MSBuild Editor issue", 3 | "command.msbuild.restartServer": "Restart MSBuild Language Server", 4 | "command.msbuild.showOutputWindow": "Show MSBuild output window", 5 | "configuration.msbuild.server.dotnetPath": "Specifies the path to a dotnet installation directory to use instead of the default system one. This only influences the dotnet installation to use for hosting the language server itself. Example: \"/home/username/my-custom-dotnet-directory\".", 6 | "configuration.msbuild.server.path": "Specifies the absolute path to the server executable. When left empty the version pinned to the MSBuild Editor Extension is used.", 7 | "configuration.msbuild.server.startTimeout": "Specifies a timeout (in ms) for the client to successfully start and connect to the language server.", 8 | "configuration.msbuild.server.waitForDebugger": "Passes the --debug flag when launching the server to allow a debugger to be attached.", 9 | "configuration.msbuild.server.trace": "Sets the logging level for the language server", 10 | "configuration.msbuild.server.crashDumpPath": "Sets a folder path where crash dumps are written to if the language server crashes. Must be writeable by the user.", 11 | "configuration.msbuild.server.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error." 12 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/completionItemMiddleware.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as lsp from 'vscode-languageclient'; 3 | 4 | export default async function completionItemMiddleware( 5 | item: vscode.CompletionItem, 6 | token: vscode.CancellationToken, 7 | next: lsp.ResolveCompletionItemSignature, 8 | ): Promise { 9 | const result = await next(item, token); 10 | if (!result) { 11 | return result; 12 | } 13 | if (result.documentation instanceof vscode.MarkdownString) { 14 | result.documentation.supportThemeIcons = true; 15 | result.documentation.isTrusted = { 16 | enabledCommands: [ 17 | 'editor.action.goToReferences' 18 | ] 19 | }; 20 | } 21 | return result; 22 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/hoverMiddleware.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as lsp from 'vscode-languageclient'; 3 | 4 | export default async function hoverMiddleware( 5 | document: vscode.TextDocument, 6 | position: vscode.Position, 7 | token: vscode.CancellationToken, 8 | next: lsp.ProvideHoverSignature, 9 | ): Promise { 10 | const result = await next(document, position, token); 11 | if (!result) { 12 | return result; 13 | } 14 | result.contents.map(content => { 15 | if (content instanceof vscode.MarkdownString) { 16 | content.supportThemeIcons = true; 17 | content.isTrusted = { 18 | enabledCommands: [ 19 | 'editor.action.goToReferences' 20 | ] 21 | }; 22 | } 23 | }); 24 | return result; 25 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/options.ts: -------------------------------------------------------------------------------- 1 | import { RoslynLanguageServerOptions } from "./roslynImport/lsptoolshost/roslynLanguageServer"; 2 | import { readOption } from "./roslynImport/shared/options"; 3 | 4 | export interface MSBuildEditorOptions extends RoslynLanguageServerOptions 5 | { 6 | } 7 | 8 | export class MSBuildEditorOptionsImpl implements MSBuildEditorOptions 9 | { 10 | public get serverPath() { 11 | return readOption('msbuild.server.path', ''); 12 | } 13 | 14 | public get startTimeout(){ 15 | return readOption('msbuild.server.startTimeout', 30000); 16 | } 17 | 18 | public get waitForDebugger(){ 19 | return readOption('msbuild.server.waitForDebugger', false); 20 | } 21 | 22 | public get logLevel(){ 23 | return readOption('msbuild.server.logLevel', 'Information'); 24 | } 25 | 26 | public get suppressLspErrorToasts(){ 27 | return readOption('msbuild.server.suppressLspErrorToasts', false); 28 | } 29 | 30 | public get dotnetPath(){ 31 | return readOption('msbuild.server.dotnetPath', ''); 32 | } 33 | 34 | public get crashDumpPath(){ 35 | return readOption('msbuild.server.crashDumpPath', undefined); 36 | } 37 | } 38 | 39 | export const msbuildEditorOptions : MSBuildEditorOptions = new MSBuildEditorOptionsImpl(); -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/compositeDisposable.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/ba156937926e760759a7e5e13bcf2d1be8729dc8/src/compositeDisposable.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | 8 | import { Subscription } from 'rxjs'; 9 | import Disposable, { IDisposable } from './disposable'; 10 | 11 | export default class CompositeDisposable extends Disposable { 12 | private disposables = new Subscription(); 13 | 14 | constructor(...disposables: IDisposable[]) { 15 | super(() => this.disposables.unsubscribe()); 16 | 17 | for (const disposable of disposables) { 18 | if (disposable) { 19 | this.add(disposable); 20 | } else { 21 | throw new Error('null disposables are not supported'); 22 | } 23 | } 24 | } 25 | 26 | public add(disposable: IDisposable) { 27 | if (!disposable) { 28 | throw new Error('disposable cannot be null'); 29 | } 30 | 31 | this.disposables.add(() => disposable.dispose()); 32 | } 33 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/disposable.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/ba156937926e760759a7e5e13bcf2d1be8729dc8/src/disposable.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | 8 | import { Subscription } from 'rxjs'; 9 | 10 | export default class Disposable implements IDisposable { 11 | private onDispose: { (): void }; 12 | 13 | constructor(onDispose: { (): void } | Subscription) { 14 | if (!onDispose) { 15 | throw new Error('onDispose cannot be null or empty.'); 16 | } 17 | 18 | if (onDispose instanceof Subscription) { 19 | this.onDispose = () => onDispose.unsubscribe(); 20 | } else { 21 | this.onDispose = onDispose; 22 | } 23 | } 24 | 25 | public dispose = (): void => { 26 | this.onDispose(); 27 | }; 28 | } 29 | 30 | export interface IDisposable { 31 | dispose: () => void; 32 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/eventStream.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/89da0f69901965627158f0120e1273ea2fc2486b/src/eventStream.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | import { Subject, Subscription } from 'rxjs'; 8 | import { BaseEvent } from './omnisharp/loggingEvents'; 9 | 10 | export class EventStream { 11 | private sink: Subject; 12 | 13 | constructor() { 14 | this.sink = new Subject(); 15 | } 16 | 17 | public post(event: BaseEvent) { 18 | this.sink.next(event); 19 | } 20 | 21 | public subscribe(eventHandler: (event: BaseEvent) => void): Subscription { 22 | return this.sink.subscribe(eventHandler); 23 | } 24 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/lsptoolshost/roslynProtocol.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/ba156937926e760759a7e5e13bcf2d1be8729dc8/src/lsptoolshost/roslynProtocol.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | 8 | import { Command } from 'vscode'; 9 | import * as lsp from 'vscode-languageserver-protocol'; 10 | 11 | export interface ShowToastNotificationParams { 12 | messageType: lsp.MessageType; 13 | message: string; 14 | commands: Command[]; 15 | } 16 | 17 | export interface NamedPipeInformation { 18 | pipeName: string; 19 | } 20 | 21 | export namespace ShowToastNotification { 22 | export const method = 'window/_roslyn_showToast'; 23 | export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.serverToClient; 24 | export const type = new lsp.NotificationType(method); 25 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/packageManager/absolutePath.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/ba156937926e760759a7e5e13bcf2d1be8729dc8/src/packageManager/absolutePath.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | 8 | import * as path from 'path'; 9 | 10 | export class AbsolutePath { 11 | constructor(public value: string) { 12 | if (!path.isAbsolute(value)) { 13 | throw new Error('The path must be absolute'); 14 | } 15 | } 16 | 17 | public static getAbsolutePath(...pathSegments: string[]): AbsolutePath { 18 | return new AbsolutePath(path.resolve(...pathSegments)); 19 | } 20 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/shared/constants/IHostExecutableResolver.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/ba156937926e760759a7e5e13bcf2d1be8729dc8/src/shared/constants/IHostExecutableResolver.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | 8 | import { HostExecutableInformation } from './hostExecutableInformation'; 9 | 10 | export interface IHostExecutableResolver { 11 | getHostExecutableInfo(): Promise; 12 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/shared/constants/hostExecutableInformation.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/ba156937926e760759a7e5e13bcf2d1be8729dc8/src/shared/constants/hostExecutableInformation.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | 8 | export interface HostExecutableInformation { 9 | version: string; 10 | path: string; 11 | env: NodeJS.ProcessEnv; 12 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/roslynImport/shared/utils/dotnetInfo.ts: -------------------------------------------------------------------------------- 1 | // https://raw.githubusercontent.com/dotnet/vscode-csharp/ba156937926e760759a7e5e13bcf2d1be8729dc8/src/shared/utils/dotnetInfo.ts 2 | 3 | /*--------------------------------------------------------------------------------------------- 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. See License.txt in the project root for license information. 6 | *--------------------------------------------------------------------------------------------*/ 7 | 8 | import * as semver from 'semver'; 9 | 10 | type RuntimeVersionMap = { [runtime: string]: RuntimeInfo[] }; 11 | export interface DotnetInfo { 12 | CliPath?: string; 13 | FullInfo: string; 14 | Version: string; 15 | /* a runtime-only install of dotnet will not output a runtimeId in dotnet --info. */ 16 | RuntimeId?: string; 17 | Architecture?: string; 18 | Runtimes: RuntimeVersionMap; 19 | } 20 | 21 | export interface RuntimeInfo { 22 | Version: semver.SemVer; 23 | Path: string; 24 | } -------------------------------------------------------------------------------- /msbuild-editor-vscode/src/test/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /msbuild-editor-vscode/syntaxes/OSSREADME.json: -------------------------------------------------------------------------------- 1 | // ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS: 2 | 3 | [{ 4 | "name": "atom/language-xml", 5 | "version": "0.0.0", 6 | "license": "MIT", 7 | "repositoryURL": "https://raw.githubusercontent.com/mono/monodevelop/master/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/xaml.json", 8 | "description": "The file msbuild.json was derived from https://raw.githubusercontent.com/mono/monodevelop/master/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/VSCodeImport/syntaxes/xaml.json, which was derived from from the Atom package https://github.com/atom/language-xml, which were originally converted from the TextMate bundle https://github.com/textmate/xml.tmbundle." 9 | 10 | }] -------------------------------------------------------------------------------- /msbuild-editor-vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "Node16", 4 | "target": "ES2022", 5 | "lib": [ 6 | "ES2022" 7 | ], 8 | "sourceMap": true, 9 | "rootDir": "src", 10 | "strict": true /* enable all strict type-checking options */ 11 | /* Additional Checks */ 12 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 13 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 14 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /private.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhutch/MonoDevelop.MSBuildEditor/c77880a6ecd589ee076cfbb1084469edbf1b58ed/private.snk -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.9", 3 | "publicReleaseRefSpec": [ 4 | "^refs/tags/v\\d+\\.\\d+$", 5 | "^refs/tags/v\\d+\\.\\d+\\.\\d+$" 6 | ], 7 | "cloudBuild": { 8 | "buildNumber": { 9 | "enabled": true 10 | } 11 | } 12 | } --------------------------------------------------------------------------------