Improved error handing for function analysis for functions in the f(y) format (#1338)

* Updated the CanFunctionAnalysisBePerformed api to use the updated one with variableIsNotX error handling. Updated the UI to reflect the new descriptive error case to show an informative error.

* Fixed spacing and updated the moved the variableIsNotX check up into the parent if statement

* Update the internals version to match the version needed to support this change
This commit is contained in:
Stephanie Anderl 2020-09-15 14:27:22 -07:00 committed by GitHub
parent bc473617ae
commit a0f98ca76b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 11 deletions

View File

@ -29,7 +29,7 @@ jobs:
downloadDirectory: $(Build.SourcesDirectory)
vstsFeed: WindowsInboxApps
vstsFeedPackage: calculator-internals
vstsPackageVersion: 0.0.49
vstsPackageVersion: 0.0.50
- template: ./build-single-architecture.yaml
parameters:

View File

@ -80,7 +80,7 @@ jobs:
downloadDirectory: $(Build.SourcesDirectory)
vstsFeed: WindowsInboxApps
vstsFeedPackage: calculator-internals
vstsPackageVersion: 0.0.49
vstsPackageVersion: 0.0.50
- powershell: |
# Just modify this line to indicate where your en-us PDP file is. Leave the other lines alone.

View File

@ -63,6 +63,10 @@ namespace CalculatorApp::ViewModel
{
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported");
}
else if (graphEquation->AnalysisError == static_cast<int>(AnalysisErrorType::VariableIsNotX))
{
AnalysisErrorString = m_resourceLoader->GetString(L"KGFVariableIsNotX");
}
return;
}

View File

@ -23,6 +23,7 @@ namespace CalculatorApp
{
NoError,
AnalysisCouldNotBePerformed,
AnalysisNotSupported
AnalysisNotSupported,
VariableIsNotX
};
}

View File

@ -4019,6 +4019,10 @@
<value>Analysis is not supported for this function.</value>
<comment>Error displayed when graph analysis is not supported or had an error.</comment>
</data>
<data name="KGFVariableIsNotX" xml:space="preserve">
<value>Analysis is only supported for functions in the f(x) format. Example: y=x</value>
<comment>Error displayed when graph analysis detects the function format is not f(x).</comment>
</data>
<data name="Maxima" xml:space="preserve">
<value>Maxima</value>
<comment>Title for KeyGraphFeatures Maxima Property</comment>

View File

@ -254,8 +254,8 @@ namespace GraphControl
vector<Equation ^> equationVector;
equationVector.push_back(equation);
UpdateGraphOptions(graph->GetOptions(), equationVector);
if (analyzer->CanFunctionAnalysisBePerformed())
bool variableIsNotX;
if (analyzer->CanFunctionAnalysisBePerformed(variableIsNotX) && !variableIsNotX)
{
if (S_OK
== analyzer->PerformFunctionAnalysis(
@ -265,6 +265,10 @@ namespace GraphControl
return KeyGraphFeaturesInfo::Create(functionAnalysisData);
}
}
else if (variableIsNotX)
{
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::VariableIsNotX);
}
else
{
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported);

View File

@ -15,10 +15,10 @@ namespace Graphing::Analyzer
struct IGraphAnalyzer : public NonCopyable, public NonMoveable
{
virtual ~IGraphAnalyzer() = default;
virtual bool CanFunctionAnalysisBePerformed() = 0;
virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0;
virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0;
virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0;
virtual ~IGraphAnalyzer() = default;
virtual bool CanFunctionAnalysisBePerformed(bool& variableIsNotX) = 0;
virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0;
virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0;
virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0;
};
}
}