private void EnsureTemplateResolutionResult() { if (_resolutionResultInitialized) { return; } _templateResolutionResult = TemplateListResolver.GetTemplateResolutionResult(_settingsLoader.UserTemplateCache.TemplateInfo, _hostDataLoader, _commandInput, _defaultLanguage); _singleMatchStatus = SingularInvokableMatchCheckStatus.None; // If any template in the group has any ambiguous params, it's not invokable. // The check for HasAmbiguousParameterValueMatch is for an example like: // "dotnet new mvc -f netcore" // - '-f netcore' is ambiguous in the 1.x version (2 begins-with matches) // - '-f netcore' is not ambiguous in the 2.x version (1 begins-with match) if (!_templateResolutionResult.TryGetUnambiguousTemplateGroupToUse(out IReadOnlyList <ITemplateMatchInfo> unambiguousTemplateGroup) || !_templateResolutionResult.TryGetSingularInvokableMatch(out _templateToInvoke, out _singleMatchStatus) || unambiguousTemplateGroup.Any(x => x.HasParameterMismatch()) || unambiguousTemplateGroup.Any(x => x.HasAmbiguousParameterValueMatch())) { _templateToInvoke = null; if (_singleMatchStatus == SingularInvokableMatchCheckStatus.AmbiguousChoice) { _environment.Host.LogDiagnosticMessage(LocalizableStrings.Authoring_AmbiguousChoiceParameterValue, "Authoring"); } else if (_singleMatchStatus == SingularInvokableMatchCheckStatus.AmbiguousPrecedence) { _environment.Host.LogDiagnosticMessage(LocalizableStrings.Authoring_AmbiguousBestPrecedence, "Authoring"); } } _resolutionResultInitialized = true; }
private async Task <CreationResultStatus> EnterTemplateManipulationFlowAsync() { TemplateListResolutionResult templateResolutionResult = QueryForTemplateMatches(); if (_commandInput.IsListFlagSpecified || _commandInput.IsHelpFlagSpecified) { return(HelpForTemplateResolution.CoordinateHelpAndUsageDisplay(templateResolutionResult, EnvironmentSettings, _commandInput, _hostDataLoader, _telemetryLogger, _templateCreator, _defaultLanguage)); } if (templateResolutionResult.TryGetUnambiguousTemplateGroupToUse(out IReadOnlyList <ITemplateMatchInfo> unambiguousTemplateGroup) && templateResolutionResult.TryGetSingularInvokableMatch(out ITemplateMatchInfo templateToInvoke) && !unambiguousTemplateGroup.Any(x => x.HasParameterMismatch()) && !unambiguousTemplateGroup.Any(x => x.HasAmbiguousParameterValueMatch())) { // If any template in the group has any ambiguous params, then don't invoke. // The check for HasAmbiguousParameterValueMatch is for an example like: // "dotnet new mvc -f netcore" // - '-f netcore' is ambiguous in the 1.x version (2 begins-with matches) // - '-f netcore' is not ambiguous in the 2.x version (1 begins-with match) return(await EnterTemplateInvocationFlowAsync(templateToInvoke).ConfigureAwait(false)); }