@@ -130,10 +130,10 @@ namespace AppInstaller::CLI::ConfigurationRemoting
130
130
return m_processorEngine;
131
131
}
132
132
133
- winrt::hstring GetFactoryMapValue (winrt::hstring key)
133
+ std::optional< winrt::hstring> GetFactoryMapValue (winrt::hstring key)
134
134
{
135
135
auto itr = m_factoryMapValues.find (key);
136
- return itr != m_factoryMapValues.end () ? itr->second : winrt::hstring{} ;
136
+ return itr != m_factoryMapValues.end () ? std::make_optional ( itr->second ) : std::nullopt ;
137
137
}
138
138
139
139
private:
@@ -340,21 +340,21 @@ namespace AppInstaller::CLI::ConfigurationRemoting
340
340
if (m_dynamicFactory->Engine () == ProcessorEngine::DSCv3)
341
341
{
342
342
winrt::hstring dscExecutablePathPropertyName = ToHString (PropertyName::DscExecutablePath);
343
- winrt::hstring dscExecutablePath = m_dynamicFactory->GetFactoryMapValue (dscExecutablePathPropertyName);
343
+ std::optional< winrt::hstring> dscExecutablePath = m_dynamicFactory->GetFactoryMapValue (dscExecutablePathPropertyName);
344
344
345
- if (dscExecutablePath. empty () )
345
+ if (! dscExecutablePath)
346
346
{
347
347
dscExecutablePath = m_dynamicFactory->Lookup (ToHString (PropertyName::FoundDscExecutablePath));
348
348
}
349
349
350
- if (dscExecutablePath. empty ())
350
+ if (dscExecutablePath-> empty ())
351
351
{
352
352
// This is backstop to prevent a case where dsc.exe not found.
353
353
AICLI_LOG (Config, Error, << " Could not find dsc.exe, it must be provided by the user." );
354
354
THROW_WIN32 (ERROR_FILE_NOT_FOUND);
355
355
}
356
356
357
- json[" processorPath" ] = Utility::ConvertToUTF8 (dscExecutablePath);
357
+ json[" processorPath" ] = Utility::ConvertToUTF8 (dscExecutablePath. value () );
358
358
}
359
359
360
360
Json::StreamWriterBuilder writerBuilder;
@@ -437,7 +437,10 @@ namespace AppInstaller::CLI::ConfigurationRemoting
437
437
});
438
438
439
439
winrt::hstring propertyName = ConfigurationRemoting::ToHString (ConfigurationRemoting::PropertyName::DiagnosticTraceEnabled);
440
- factory.as <Collections::IMap<winrt::hstring, winrt::hstring>>().Insert (propertyName, m_dynamicFactory->GetFactoryMapValue (propertyName));
440
+ if (auto propertyValue = m_dynamicFactory->GetFactoryMapValue (propertyName))
441
+ {
442
+ factory.as <Collections::IMap<winrt::hstring, winrt::hstring>>().Insert (propertyName, propertyValue.value ());
443
+ }
441
444
}
442
445
443
446
return m_setProcessors.emplace (integrityLevel, DynamicProcessorInfo{ factory, factory.CreateSetProcessor (m_configurationSet), std::move (factoryDiagnosticsEventRevoker) }).first ;
0 commit comments