Skip to content

Commit 169e32a

Browse files
trgibeaumslukebo
andauthored
Update Samples to 1.0 RC1 (#183)
* Update Samples to 1.0 RC1 * Updates based on PR comments Co-authored-by: Luke Bordonaro <lukebo@microsoft.com>
1 parent 86ebf45 commit 169e32a

16 files changed

+105
-117
lines changed

samples/SimpleDataSource/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Introduction
2-
This sample plugin consists of a single Custom Data Source (CDS) that understands files with the `.txt` extension and a Custom Data Processor that processes simple text files with the following format:
2+
This sample plugin consists of a single Processing Source that understands files with the `.txt` extension and a Custom Data Processor that processes simple text files with the following format:
33

44
```
55
2/4/2019 9:40:00 AM, Word1 Word2 Word3 ...
@@ -15,5 +15,5 @@ See `SampleTextFile.txt` for an example of a file with this format.
1515
2. [.NET Standard 2.0](https://dotnet.microsoft.com/download/visual-studio-sdks)
1616

1717
# Instructions
18-
Please refer to [Using the SDK/Creating a Simple Custom Data Source](../../documentaiton/Using-the-SDK/Creating-a-simple-custom-data-source.md) for details
18+
Please refer to [Using the SDK/Creating a Simple SDK Plugin](../../documentaiton/Using-the-SDK/Creating-a-simple-sdk-plugin.md) for details
1919
on how to implement this source code.

samples/SimpleDataSource/SampleAddIn.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.0" />
8+
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.14-rc1" />
99
</ItemGroup>
1010

1111
</Project>

samples/SimpleDataSource/SimpleCustomDataProcessor.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ namespace SampleCustomDataSource
1717
//
1818
// This is a sample Custom Data Processor that processes simple text files.
1919
//
20-
// Custom Data Processors are created in Custom Data Sources and are used to actually process the file(s).
21-
// An instance of this Processor is created for each set of files opened whereas only one instance of the Custom Data Source is ever created.
22-
// Note that CustomDataProcessorBase does not require any file(s) in its constructor, so another
23-
// implementation might only store/process one file per instance.
20+
// Custom Data Processors are created by a Processing Source and are used to actually process the source(s).
21+
// An instance of this Processor is created for each set of sources opened whereas only one instance of the Processing Source is ever created.
22+
// Note that CustomDataProcessor does not require any source(s) in its constructor, so another
23+
// implementation might only store/process one source per instance.
2424
//
2525
// The data processor is responsible for instantiating the proper tables based on what the user has decided to enable.
2626
// To receive a callback whenever a new table is enabled, implement OnTableEnabled. This sample does not implement
2727
// this callback, and assumes every table is enabled.
2828
//
2929

3030
//
31-
// Derive the CustomDataProcessorBase abstract class.
31+
// Derive the CustomDataProcessor abstract class.
3232
//
3333

3434
public sealed class SimpleCustomDataProcessor
35-
: CustomDataProcessorBase
35+
: CustomDataProcessor
3636
{
3737
// The files this custom data processor will have to process
3838
private readonly string[] filePaths;
@@ -51,10 +51,8 @@ public SimpleCustomDataProcessor(
5151
string[] filePaths,
5252
ProcessorOptions options,
5353
IApplicationEnvironment applicationEnvironment,
54-
IProcessorEnvironment processorEnvironment,
55-
IReadOnlyDictionary<TableDescriptor, Action<ITableBuilder, IDataExtensionRetrieval>> allTablesMapping,
56-
IEnumerable<TableDescriptor> metadataTables)
57-
: base(options, applicationEnvironment, processorEnvironment, allTablesMapping, metadataTables)
54+
IProcessorEnvironment processorEnvironment)
55+
: base(options, applicationEnvironment, processorEnvironment)
5856
{
5957
this.filePaths = filePaths;
6058
}
@@ -78,7 +76,7 @@ protected override Task ProcessAsyncCore(
7876
// In this sample, we take down the start and stop timestamps from the files
7977
//
8078
// Note: if you must do processing based on which tables are enabled, you would check the EnabledTables property
81-
// (provided in the base class) on your class to see what you should do. For example, a custom data source with
79+
// (provided in the base class) on your class to see what you should do. For example, a processing source with
8280
// many disjoint tables may look at what tables are enabled in order to turn on only specific processors to avoid
8381
// processing everything if it doesn't have to.
8482
//
@@ -188,7 +186,6 @@ protected override Task ProcessAsyncCore(
188186

189187
protected override void BuildTableCore(
190188
TableDescriptor tableDescriptor,
191-
Action<ITableBuilder, IDataExtensionRetrieval> buildTableAction,
192189
ITableBuilder tableBuilder)
193190
{
194191
//

samples/SimpleDataSource/SimpleCustomDataSource.cs renamed to samples/SimpleDataSource/SimpleProcessingSource.cs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,57 @@
88
namespace SampleCustomDataSource
99
{
1010
//
11-
// This is a sample Custom Data Source (CDS) that understands files with the .txt extension
11+
// This is a sample Processing Source that understands files with the .txt extension
1212
//
1313

1414
//
15-
// In order for a CDS to be recognized, it MUST satisfy the following:
15+
// In order for a processing source to be recognized, it MUST satisfy the following:
1616
// a) Be a public type
1717
// b) Have a public parameterless constructor
18-
// c) Implement the ICustomDataSource interface
19-
// d) Be decorated with the CustomDataSourceAttribute attribute
18+
// c) Implement the IProcessingSource interface
19+
// d) Be decorated with the ProcessingSourceAttribute attribute
2020
// e) Be decorated with at least one of the derivatives of the DataSourceAttribute attribute
2121
//
2222

23-
[CustomDataSource(
24-
"{F73EACD4-1AE9-4844-80B9-EB77396781D1}", // The GUID must be unique for your Custom Data Source. You can use Visual Studio's Tools -> Create Guid… tool to create a new GUID
25-
"Simple Data Source", // The Custom Data Source MUST have a name
26-
"A data source to count words!")] // The Custom Data Source MUST have a description
23+
[ProcessingSource(
24+
"{F73EACD4-1AE9-4844-80B9-EB77396781D1}", // The GUID must be unique for your Processing Source. You can use Visual Studio's Tools -> Create Guid… tool to create a new GUID
25+
"Simple Data Source", // The Processing Source MUST have a name
26+
"A data source to count words!")] // The Processing Source MUST have a description
2727
[FileDataSource(
2828
".txt", // A file extension is REQUIRED
2929
"Text files")] // A description is OPTIONAL. The description is what appears in the file open menu to help users understand what the file type actually is.
3030

3131
//
32-
// There are two methods to creating a Custom Data Source that is recognized by the SDK:
32+
// There are two methods to creating a Processing Source that is recognized by the SDK:
3333
// 1. Using the helper abstract base classes
3434
// 2. Implementing the raw interfaces
3535
// This sample demonstrates method 1 where the CustomDataSourceBase abstract class
3636
// helps provide a public parameterless constructor and implement the ICustomDataSource interface
3737
//
3838

39-
public class SimpleCustomDataSource
40-
: CustomDataSourceBase
39+
public class SimpleProcessingSource
40+
: ProcessingSource
4141
{
4242
private IApplicationEnvironment applicationEnvironment;
4343

4444
//
45-
// Provides information about this Custom Data Source, such as the author,
45+
// Provides information about this Processing Source, such as the author,
4646
// a project link, licensing, etc. This information can be used by tools
47-
// to display "About" information for your Custom Data Source. For example,
47+
// to display "About" information for your Processing Source. For example,
4848
// Windows Performance Analyzer (WPA) uses this information for Help->About.
4949
//
5050

51-
public override CustomDataSourceInfo GetAboutInfo()
51+
public override ProcessingSourceInfo GetAboutInfo()
5252
{
53-
return new CustomDataSourceInfo
53+
return new ProcessingSourceInfo
5454
{
5555
//
56-
// The copyright notice for this Custom Data Source.
56+
// The copyright notice for this Processing Source.
5757
//
5858
CopyrightNotice = "Copyright 2021 Microsoft Corporation. All Rights Reserved.",
5959

6060
//
61-
// The license under which this Custom Data Source may be used.
61+
// The license under which this Processing Source may be used.
6262
//
6363
LicenseInfo = new LicenseInfo
6464
{
@@ -68,7 +68,7 @@ public override CustomDataSourceInfo GetAboutInfo()
6868
},
6969

7070
//
71-
// A collection of the people or entities that own this Custom Data Source.
71+
// A collection of the people or entities that own this Processing Source.
7272
//
7373
Owners = new[]
7474
{
@@ -91,11 +91,11 @@ public override CustomDataSourceInfo GetAboutInfo()
9191
},
9292

9393
//
94-
// Any additional information you wish your users to know about this Custom Data Source.
94+
// Any additional information you wish your users to know about this Processing Source.
9595
//
9696
AdditionalInformation = new[]
9797
{
98-
"This Custom Data Source is a sample showcasing the Performance Toolkit SDK.",
98+
"This Processing Source is a sample showcasing the Performance Toolkit SDK.",
9999
}
100100
};
101101
}
@@ -121,24 +121,22 @@ protected override ICustomDataProcessor CreateProcessorCore(
121121
{
122122
//
123123
// Create a new instance of a class implementing ICustomDataProcessor here to process the specified data sources.
124-
// Note that you can have more advanced logic here to create different processors if you would like based on the file, or any other criteria.
124+
// Note that you can have more advanced logic here to create different processors if you would like based on the source, or any other criteria.
125125
// You are not restricted to always returning the same type from this method.
126126
//
127127

128128
return new SimpleCustomDataProcessor(
129-
dataSources.Select(x => x.GetUri().LocalPath).ToArray(),
129+
dataSources.Select(x => x.Uri.LocalPath).ToArray(),
130130
options,
131131
this.applicationEnvironment,
132-
processorEnvironment,
133-
this.AllTables,
134-
this.MetadataTables);
132+
processorEnvironment);
135133
}
136134

137-
protected override bool IsFileSupportedCore(string path)
135+
protected override bool IsDataSourceSupportedCore(IDataSource source)
138136
{
139137
//
140-
// This method is called for every file whose filetype matches the one declared in the FileDataSource attribute. It may be useful
141-
// to peek inside the file to truly determine if you can support it, especially if your CDS supports a common
138+
// This method is called for every data source which matches the one declared in the DataSource attribute. It may be useful
139+
// to peek inside the source to truly determine if you can support it, especially if your data processor supports a common
142140
// filetype like .txt or .csv.
143141
// For this sample, we'll always return true for simplicity.
144142
//

samples/SimpleDataSource/Tables/WordTable.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ public override void Build(ITableBuilder tableBuilder)
119119
TableConfiguration.GraphColumn,
120120
TimeColumn,
121121
},
122-
Layout = TableLayoutStyle.GraphAndTable,
123122
};
124123

125124
//

samples/SqlPlugin/SqlPlugin/SqlCustomDataProcessor.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
using Microsoft.Performance.SDK;
5-
using Microsoft.Performance.SDK.Extensibility;
65
using Microsoft.Performance.SDK.Processing;
76
using System;
87
using System.Collections.Generic;
@@ -16,11 +15,11 @@
1615
namespace SqlPlugin
1716
{
1817
public class SqlCustomDataProcessor
19-
: CustomDataProcessorBase
18+
: CustomDataProcessor
2019
{
2120
// XML file to be parsed. For this demo, we assume we only have one data source.
2221
// For a full implementation, this should be a collection of all file paths given
23-
// to the Custom Data Source
22+
// to the Processing Source
2423
private readonly string filePath;
2524

2625
// Information about this data source the SDK requires for building tables
@@ -38,10 +37,8 @@ public class SqlCustomDataProcessor
3837
public SqlCustomDataProcessor(string filePath,
3938
ProcessorOptions options,
4039
IApplicationEnvironment applicationEnvironment,
41-
IProcessorEnvironment processorEnvironment,
42-
IReadOnlyDictionary<TableDescriptor, Action<ITableBuilder, IDataExtensionRetrieval>> allTablesMapping,
43-
IEnumerable<TableDescriptor> metadataTables)
44-
: base(options, applicationEnvironment, processorEnvironment, allTablesMapping, metadataTables)
40+
IProcessorEnvironment processorEnvironment)
41+
: base(options, applicationEnvironment, processorEnvironment)
4542
{
4643
this.filePath = filePath;
4744
}
@@ -218,9 +215,7 @@ private List<SqlEvent> ParseXml(IProgress<int> progress)
218215
return sqlEvents;
219216
}
220217

221-
protected override void BuildTableCore(TableDescriptor tableDescriptor,
222-
Action<ITableBuilder, IDataExtensionRetrieval> createTable,
223-
ITableBuilder tableBuilder)
218+
protected override void BuildTableCore(TableDescriptor tableDescriptor, ITableBuilder tableBuilder)
224219
{
225220
//
226221
// Normally, we would use the TableDescriptor to figure out which Table needs to be created.

samples/SqlPlugin/SqlPlugin/SqlPlugin.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
9+
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.14-rc1" />
1010
</ItemGroup>
1111

1212
</Project>

samples/SqlPlugin/SqlPlugin/SqlCustomDataSource.cs renamed to samples/SqlPlugin/SqlPlugin/SqlProcessingSource.cs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
namespace SqlPlugin
1010
{
11-
[CustomDataSource("7309FAED-6A34-4FD1-8551-7AEB5006C71E",
11+
[ProcessingSource("7309FAED-6A34-4FD1-8551-7AEB5006C71E",
1212
"SQL Trace Data Source",
1313
"Processes SQL trace files exported as XML.")]
1414
[FileDataSource(".xml", "XML files exported from TRC files")]
15-
public class SqlCustomDataSource
16-
: CustomDataSourceBase
15+
public class SqlProcessingSource
16+
: ProcessingSource
1717
{
1818
private IApplicationEnvironment applicationEnvironment;
1919

20-
public override CustomDataSourceInfo GetAboutInfo()
20+
public override ProcessingSourceInfo GetAboutInfo()
2121
{
22-
return new CustomDataSourceInfo
22+
return new ProcessingSourceInfo
2323
{
2424
CopyrightNotice = "Copyright 2021 Microsoft Corporation. All Rights Reserved.",
2525
LicenseInfo = new LicenseInfo
@@ -56,35 +56,38 @@ protected override ICustomDataProcessor CreateProcessorCore(IEnumerable<IDataSou
5656
// plugin, every data source should be used.
5757
//
5858

59-
var filePath = dataSources.First().GetUri().LocalPath;
59+
var filePath = dataSources.First().Uri.LocalPath;
6060
return new SqlCustomDataProcessor(filePath,
6161
options,
6262
this.applicationEnvironment,
63-
processorEnvironment,
64-
this.AllTables,
65-
this.MetadataTables);
63+
processorEnvironment);
6664
}
6765

68-
protected override bool IsFileSupportedCore(string path)
66+
protected override bool IsDataSourceSupportedCore(IDataSource source)
6967
{
70-
// Peek inside the XML and make sure our XML namespace is declared and used
71-
72-
using (var reader = new StreamReader(path))
68+
if (source is FileDataSource fileDataSource)
7369
{
74-
// Skip first line since namespace should be on second
75-
reader.ReadLine();
76-
77-
var line = reader.ReadLine();
70+
// Peek inside the XML and make sure our XML namespace is declared and used
7871

79-
if (line != null)
72+
using (var reader = new StreamReader(fileDataSource.FullPath))
8073
{
81-
return line.Contains(SqlPluginConstants.SqlXmlNamespace);
82-
}
83-
else
84-
{
85-
return false;
74+
// Skip first line since namespace should be on second
75+
reader.ReadLine();
76+
77+
var line = reader.ReadLine();
78+
79+
if (line != null)
80+
{
81+
return line.Contains(SqlPluginConstants.SqlXmlNamespace);
82+
}
83+
else
84+
{
85+
return false;
86+
}
8687
}
8788
}
89+
90+
return false;
8891
}
8992

9093
protected override void SetApplicationEnvironmentCore(IApplicationEnvironment applicationEnvironment)

samples/SqlPlugin/SqlPlugin/SqlTable.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ internal void Build(ITableBuilder tableBuilder)
162162
TableConfiguration.RightFreezeColumn,
163163
TableConfiguration.GraphColumn,
164164
RelativeTimestampColumn
165-
},
166-
Layout = TableLayoutStyle.GraphAndTable
165+
}
167166
};
168167

169168
//

samples/SqlPlugin/SqlPluginWithProcessingPipeline/SqlCustomDataProcessorWithSourceParser.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using Microsoft.Performance.SDK.Extensibility;
54
using Microsoft.Performance.SDK.Extensibility.SourceParsing;
65
using Microsoft.Performance.SDK.Processing;
7-
using System;
8-
using System.Collections.Generic;
96

107
namespace SqlPluginWithProcessingPipeline
118
{
@@ -16,16 +13,14 @@ namespace SqlPluginWithProcessingPipeline
1613
/// gets built.
1714
/// </summary>
1815
public class SqlCustomDataProcessorWithSourceParser
19-
: CustomDataProcessorBaseWithSourceParser<SqlEvent, SqlSourceParser, string>
16+
: CustomDataProcessorWithSourceParser<SqlEvent, SqlSourceParser, string>
2017
{
2118
internal SqlCustomDataProcessorWithSourceParser(
2219
ISourceParser<SqlEvent, SqlSourceParser, string> sourceParser,
2320
ProcessorOptions options,
2421
IApplicationEnvironment applicationEnvironment,
25-
IProcessorEnvironment processorEnvironment,
26-
IReadOnlyDictionary<TableDescriptor, Action<ITableBuilder, IDataExtensionRetrieval>> allTablesMapping,
27-
IEnumerable<TableDescriptor> metadataTables)
28-
: base(sourceParser, options, applicationEnvironment, processorEnvironment, allTablesMapping, metadataTables)
22+
IProcessorEnvironment processorEnvironment)
23+
: base(sourceParser, options, applicationEnvironment, processorEnvironment)
2924
{
3025
}
3126
}

0 commit comments

Comments
 (0)