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

Load data collector #336

Closed
wants to merge 2 commits into from
Closed

Load data collector #336

wants to merge 2 commits into from

Conversation

harshjain2
Copy link
Contributor

Load data collector

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.Atrributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Atrributes/Attributes.

Not sure if Attributes should be a new namespace.

/// <summary>
/// Provides a friendly name for the data collector.
/// </summary>
public class DataCollecetorFriendlyNameAttribute : Attribute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Collecetor/Collector

}

[TestMethod]
public void InitializeDataCollectorShouldNotAddDataCollectorIfUriIsNotSpecified()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in this test you are specifying the uri, am I missing here something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it to InitializeDataCollectorShouldNotAddDataCollectorIfUriIsNotSpecifiedByDataCollector

The scenario is that the data collector class hasn't declared value for attribute TypeUri.


[DataCollecetorFriendlyName("CustomDataCollector")]
[DataCollectorTypeUri("my://custom/datacollector")]
public class CustomDataCollector : DataCollector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: can we rename it to CustomDataCollectorWithUri because the below one is CustomDataCollectorWithoutUri. What you say?

/// <inheritdoc/>
public void Dispose()
{
throw new NotImplementedException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove IDisposable if it is not implemented yet.

}
catch (Exception ex)
{
if (EqtTrace.IsErrorEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does error handling work for datacollector.exe? Which log file do these messages go in?

}

/// <summary>
/// The get data collector information from binary.
Copy link
Contributor

@codito codito Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace the default text. Same comment for other methods.

assembly = LoadAssemblyFromPath(dllPath);
}

if (assembly == null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for supporting executable data collectors?

assembly = null;
Type dctype = null;
var dllPath = string.Concat(binaryPath, ".dll");
if (File.Exists(dllPath))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we testing this logic with File.Exists?

if (dataCollectorType == null)
{
// Try to find the data collector in the source directory
basePath = Path.Combine(SourceDirectory, collectorTypeName.Split(',')[1].Trim());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't seem intuitive. If we're shipping CC DataCollector v1.0 in extensions folder; user can never use a v2.0 via nuget package?

if (dataCollectorType == null)
{
// Try to find the data collector in the source directory
basePath = Path.Combine(SourceDirectory, collectorTypeName.Split(',')[1].Trim());
Copy link
Contributor

@codito codito Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Is there an assumption that datacollector names are fullyqualified? Is there any base class API which parses an fully qualified AssemblyName?

Same comment for Line 132.


// todo : get the config file.
// var configuration = DataCollectorDiscoveryHelper.GetConfigurationForAssembly(assembly);
var configuration = string.Empty;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add these TODO as tasks in #309?

var dataCollector = CreateDataCollector(dataCollectorConfig.DataCollectorType);

// Attempt to get the data collector information verifying that all of the required metadata for the collector is available.
testplatformDataCollector = dataCollectorConfig == null ? null : new TestPlatformDataCollector(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent


try
{
var dataCollector = CreateDataCollector(dataCollectorConfig.DataCollectorType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if dataCollector is null?

dataCollector and testplatformDataCollector names are confusing. Please consider rename.

}
catch (Exception)
{
// data collector failed to initialize. Dispose it and mark it failed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add todo here or log this with EqtTrace

this.DataCollectorConfiguration = dataCollectorConfig;
this.TypeUri = GetTypeUri(type);

// todo : initialize FriendlyName.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a todo?

@@ -1,8 +1,11 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider making datacollector executable AnyCpu.

internal DataCollectionManager(IList<string> sources)
{
this.RunDataCollectors = new Dictionary<Type, TestPlatformDataCollector>();
SourceDirectory = Path.GetDirectoryName(sources.First());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear why we are setting the SourceDirectory to just the first source.

@harshjain2 harshjain2 closed this Jan 17, 2017
@harshjain2
Copy link
Contributor Author

Closing this PR, will raise a new PR against future branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants