mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
resolve TODO items
This commit is contained in:
parent
40ad24ff7c
commit
00e4dc908c
7 changed files with 19 additions and 36 deletions
|
@ -15,29 +15,17 @@ namespace CalculatorApp::ViewModel
|
|||
private:
|
||||
LocalizationSettings()
|
||||
// Use DecimalFormatter as it respects the locale and the user setting
|
||||
// CSHARP_MIGRATION: TODO:
|
||||
//: LocalizationSettings(LocalizationService::GetInstance()->GetRegionalSettingsAwareDecimalFormatter())
|
||||
{
|
||||
InitializeLocalizationSettings(LocalizationService::GetInstance()->GetRegionalSettingsAwareDecimalFormatter());
|
||||
Initialize(LocalizationService::GetInstance()->GetRegionalSettingsAwareDecimalFormatter());
|
||||
}
|
||||
|
||||
public:
|
||||
// This is only public for unit testing purposes.
|
||||
LocalizationSettings(Windows::Globalization::NumberFormatting::DecimalFormatter ^ formatter)
|
||||
{
|
||||
InitializeLocalizationSettings(formatter);
|
||||
Initialize(formatter);
|
||||
}
|
||||
|
||||
// A LocalizationSettings object is not copyable.
|
||||
// CSHARP_MIGRATION: TODO: deleted and defaulted functions are not supported in managed/WinRT classes
|
||||
//LocalizationSettings(const LocalizationSettings^) = delete;
|
||||
//LocalizationSettings^ operator=(const LocalizationSettings^) = delete;
|
||||
|
||||
// A LocalizationSettings object is not moveable.
|
||||
// CSHARP_MIGRATION: TODO: Double check how should we hanlde move constrcutor and move assignment
|
||||
//LocalizationSettings(LocalizationSettings&&) = delete;
|
||||
//LocalizationSettings& operator=(LocalizationSettings&&) = delete;
|
||||
|
||||
// Provider of the singleton LocalizationSettings instance.
|
||||
static LocalizationSettings^ GetInstance()
|
||||
{
|
||||
|
@ -202,7 +190,7 @@ namespace CalculatorApp::ViewModel
|
|||
|
||||
|
||||
private:
|
||||
void InitializeLocalizationSettings(Windows::Globalization::NumberFormatting::DecimalFormatter ^ formatter)
|
||||
void Initialize(Windows::Globalization::NumberFormatting::DecimalFormatter ^ formatter)
|
||||
{
|
||||
formatter->FractionDigits = 0;
|
||||
formatter->IsDecimalPointAlwaysDisplayed = false;
|
||||
|
|
|
@ -148,16 +148,21 @@ namespace CalculatorApp
|
|||
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_EXCEPTION), fields);
|
||||
}
|
||||
|
||||
void TraceLogger::LogPlatformException(ViewMode mode, Platform::String ^ functionName, Platform::Exception ^ e)
|
||||
void TraceLogger::LogPlatformExceptionInfo(CalculatorApp::ViewModel::Common::ViewMode mode, Platform::String ^ functionName, Platform::String^ message, int hresult)
|
||||
{
|
||||
auto fields = ref new LoggingFields();
|
||||
fields->AddString(StringReference(CALC_MODE), NavCategory::GetFriendlyName(mode));
|
||||
fields->AddString(StringReference(L"FunctionName"), functionName);
|
||||
fields->AddString(StringReference(L"Message"), e->Message);
|
||||
fields->AddInt32(StringReference(L"HRESULT"), e->HResult);
|
||||
fields->AddString(StringReference(L"Message"), message);
|
||||
fields->AddInt32(StringReference(L"HRESULT"), hresult);
|
||||
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_EXCEPTION), fields);
|
||||
}
|
||||
|
||||
void TraceLogger::LogPlatformException(ViewMode mode, Platform::String ^ functionName, Platform::Exception ^ e)
|
||||
{
|
||||
LogPlatformExceptionInfo(mode, functionName, e->Message, e->HResult);
|
||||
}
|
||||
|
||||
void TraceLogger::UpdateButtonUsage(NumbersAndOperatorsEnum button, ViewMode mode)
|
||||
{
|
||||
// IsProgrammerMode, IsScientificMode, IsStandardMode and None are not actual buttons, so ignore them
|
||||
|
|
|
@ -83,12 +83,12 @@ namespace CalculatorApp::ViewModel::Common
|
|||
void LogVariableSettingsChanged(Platform::String ^ setting);
|
||||
void LogGraphSettingsChanged(GraphSettingsType settingsType, Platform::String ^ settingValue);
|
||||
void LogGraphTheme(Platform::String ^ graphTheme);
|
||||
void LogInputPasted(CalculatorApp::ViewModel::Common::ViewMode mode);
|
||||
void LogPlatformExceptionInfo(CalculatorApp::ViewModel::Common::ViewMode mode, Platform::String ^ functionName, Platform::String ^ message, int hresult);
|
||||
|
||||
internal:
|
||||
// CSHARP_MIGRATION: TODO:
|
||||
void LogPlatformException(CalculatorApp::ViewModel::Common::ViewMode mode, Platform::String ^ functionName, Platform::Exception ^ e);
|
||||
void LogStandardException(CalculatorApp::ViewModel::Common::ViewMode mode, std::wstring_view functionName, _In_ const std::exception& e);
|
||||
void LogInputPasted(CalculatorApp::ViewModel::Common::ViewMode mode);
|
||||
|
||||
private:
|
||||
// Create an instance of TraceLogger
|
||||
|
|
|
@ -708,7 +708,8 @@ namespace CalculatorApp
|
|||
|
||||
namespace ViewModel::Common
|
||||
{
|
||||
// CSHARP_MIGRATION: TODO: Review below utils
|
||||
// below utilities are intended to support interops between C# and C++/CX
|
||||
// they can be removed if the entire codebase has been migrated to C#
|
||||
public ref class Utilities sealed
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -734,8 +734,6 @@ namespace CalculatorApp
|
|||
}
|
||||
}
|
||||
|
||||
// CSHARP_MIGRATION: TODO: reinterpreted SortedDictionary<MyVirtualKey, List<WeakReference>> to SortedDictionary<char, List<WeakReference>>
|
||||
// double check this is equivalent before and after migration
|
||||
private static SortedDictionary<MyVirtualKey, List<WeakReference>> GetCurrentKeyDictionary(bool controlKeyPressed, bool shiftKeyPressed, bool altPressed)
|
||||
{
|
||||
int viewId = Utilities.GetWindowId();
|
||||
|
@ -785,7 +783,6 @@ namespace CalculatorApp
|
|||
}
|
||||
}
|
||||
|
||||
// CSHARP_MIGRATION: TODO: double check below design
|
||||
// EqualRange is a helper function to pick a range from std::multimap.
|
||||
private static IEnumerable<TValue> EqualRange<TKey, TValue>(SortedDictionary<TKey, List<TValue>> source, TKey key)
|
||||
{
|
||||
|
@ -800,7 +797,6 @@ namespace CalculatorApp
|
|||
}
|
||||
}
|
||||
|
||||
// CSHARP_MIGRATION: TODO: double check below design
|
||||
// Insert is a helper function to insert a pair into std::multimap.
|
||||
private static void Insert<Tkey, TValue>(SortedDictionary<Tkey, List<TValue>> dest, Tkey key, TValue value)
|
||||
{
|
||||
|
|
|
@ -353,13 +353,11 @@ namespace CalculatorApp
|
|||
catch (System.Runtime.InteropServices.COMException ex)
|
||||
{
|
||||
// COMException and HResult, long RPC_E_SERVERCALL_RETRYLATER is out of range of int
|
||||
// LogPlatformException is internal
|
||||
long rpc_e_servercall_retrylater = 0x8001010A;
|
||||
if (ex.HResult == unchecked(rpc_e_servercall_retrylater))
|
||||
{
|
||||
ShowShareError();
|
||||
// CSHARP_MIGRATION: TODO:
|
||||
//TraceLogger.GetInstance().LogPlatformException(ViewMode.Graphing, System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
|
||||
CalculatorApp.ViewModel.Common.TraceLogger.GetInstance().LogPlatformExceptionInfo(ViewMode.Graphing, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message, ex.HResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -505,10 +503,7 @@ namespace CalculatorApp
|
|||
catch (Exception ex)
|
||||
{
|
||||
ShowShareError();
|
||||
|
||||
// CSHARP_MIGRATION: TODO:
|
||||
//TraceLogger.GetInstance().LogPlatformException(ViewMode.Graphing,
|
||||
// System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
|
||||
CalculatorApp.ViewModel.Common.TraceLogger.GetInstance().LogPlatformExceptionInfo(ViewMode.Graphing, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message, ex.HResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,11 +110,9 @@ namespace CalculatorApp
|
|||
{
|
||||
if (e.Key == VirtualKey.Enter)
|
||||
{
|
||||
// CSHARP_MIGRATION: TODO:
|
||||
// check if condition
|
||||
if (FocusManager.TryMoveFocusAsync(FocusNavigationDirection.Next).Status != AsyncStatus.Completed)
|
||||
if (FocusManager.TryMoveFocusAsync(FocusNavigationDirection.Next) == null)
|
||||
{
|
||||
IAsyncOperation<FocusMovementResult> result = FocusManager.TryMoveFocusAsync(FocusNavigationDirection.Previous);
|
||||
_ = FocusManager.TryMoveFocusAsync(FocusNavigationDirection.Previous);
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue