Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataCollector check with only Uri in Runsettings #2177

Merged
Expand Up @@ -391,6 +391,24 @@ protected virtual bool TryGetUriFromFriendlyName(string friendlyName, out string
return false;
}

protected virtual bool IsUriValid(string uri)
{
if (string.IsNullOrEmpty(uri))
{
return false;
}

var extensionManager = this.dataCollectorExtensionManager;
hvinett marked this conversation as resolved.
Show resolved Hide resolved
foreach (var extension in extensionManager.TestExtensions)
{
if (string.Compare(uri, extension.Metadata.ExtensionUri, StringComparison.OrdinalIgnoreCase) == 0)
{
return true;
}
}
return false;
}

/// <summary>
/// Gets the extension using uri.
/// </summary>
Expand Down Expand Up @@ -421,8 +439,12 @@ private void LoadAndInitialize(DataCollectorSettings dataCollectorSettings, stri
{
// Look up the extension and initialize it if one is found.
var extensionManager = this.DataCollectorExtensionManager;
var dataCollectorUri = string.Empty;
this.TryGetUriFromFriendlyName(dataCollectorSettings.FriendlyName, out dataCollectorUri);
var dataCollectorUri = dataCollectorSettings.Uri?.ToString();

if (!IsUriValid(dataCollectorUri) && !this.TryGetUriFromFriendlyName(dataCollectorSettings.FriendlyName, out dataCollectorUri))
{
this.LogWarning(string.Format(CultureInfo.CurrentUICulture, Resources.Resources.UnableToFetchUriString, dataCollectorSettings.FriendlyName));
}

DataCollector dataCollector = null;
if (!string.IsNullOrWhiteSpace(dataCollectorUri))
Expand Down Expand Up @@ -699,4 +721,4 @@ private void LogAttachments(List<AttachmentSet> attachmentSets)
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/Resources.resx
Expand Up @@ -213,6 +213,9 @@
<data name="TestCaseFilterFormatException" xml:space="preserve">
<value>Incorrect format for TestCaseFilter {0}. Specify the correct format and try again. Note that the incorrect format can lead to no test getting executed.</value>
</data>
<data name="UnableToFetchUriString" xml:space="preserve">
<value>Unable to find a datacollector with friendly name '[0}'.</value>
</data>
<data name="VSInstallationNotFound" xml:space="preserve">
<value>This option works only with vstest.console.exe installed as part of Visual Studio.</value>
</data>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Operace se ruší na základě žádosti.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Der Vorgang wird gemäß Anforderung abgebrochen.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">La operación se cancelará como se ha solicitado.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Annulation de l'opération, comme demandé.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">L'operazione verrà annullata come richiesto.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">操作のキャンセルが要求されたため、キャンセルしています。</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">요청한 대로 작업을 취소하는 중입니다.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Anulowanie operacji zgodnie z żądaniem.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Cancelando a operação conforme solicitado.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Операция отменяется в соответствии с запросом.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">İşlem istek üzerine iptal ediliyor.</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf
Expand Up @@ -146,6 +146,11 @@
<target state="new">Cancelling the operation as requested.</target>
<note></note>
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">按要求取消该操作。</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -269,6 +269,11 @@
<target state="translated">正在應要求取消作業。</target>
<note />
</trans-unit>
<trans-unit id="UnableToFetchUriString">
<source>Unable to find a datacollector with friendly name '[0}'.</source>
<target state="new">Unable to find a datacollector with friendly name '[0}'.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
Expand Down
Expand Up @@ -28,7 +28,7 @@ internal static IDataCollectionLauncher GetDataCollectorLauncher(IProcessHelper
var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settingsXml);
foreach (var dataCollectorSettings in dataCollectionRunSettings.DataCollectorSettingsList)
{
if (dataCollectorSettings.FriendlyName.ToLower().Equals("event log"))
if (string.Equals(dataCollectorSettings.FriendlyName, "event Log", StringComparison.OrdinalIgnoreCase) || string.Equals(dataCollectorSettings.Uri?.ToString(), @"datacollector://Microsoft/EventLog/2.0", StringComparison.OrdinalIgnoreCase))
{
return new DefaultDataCollectionLauncher();
}
Expand Down
Expand Up @@ -201,12 +201,6 @@ internal static DataCollectorSettings FromXml(XmlReader reader)

}

if (string.IsNullOrWhiteSpace(settings.FriendlyName))
{
throw new SettingsException(
String.Format(CultureInfo.CurrentCulture, Resources.Resources.MissingDataCollectorAttributes, "FriendlyName"));
}

reader.Read();
if (!empty)
{
Expand Down