Skip to content

Commit 8c201f4

Browse files
committed
Include required properties on all ProcessingSourceInfo instances returned by processing sources
1 parent 144d42c commit 8c201f4

File tree

7 files changed

+94
-57
lines changed

7 files changed

+94
-57
lines changed

LTTngCds/LTTngCds.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
<ItemGroup>
3535
<ProjectReference Include="..\CtfPlayback\CtfPlayback.csproj" />
36+
<ProjectReference Include="..\Utilities\Utilities.csproj" />
3637
</ItemGroup>
3738

3839
</Project>

LTTngCds/LTTngDataSource.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using Microsoft.Performance.SDK;
99
using Microsoft.Performance.SDK.Processing;
10+
using Utilities;
1011

1112
namespace LTTngCds
1213
{
@@ -22,7 +23,7 @@ public class LTTngDataSource
2223
private IApplicationEnvironment applicationEnvironment;
2324

2425
/// <inheritdoc />
25-
public override IEnumerable<Option> CommandLineOptions => new List<Option> { new Option("LTTngOffsetTime", "offsetTime", 1, 1) };
26+
public override IEnumerable<Option> CommandLineOptions => new List<Option> { new Option("LTTngOffsetTime", "offsetTime", 1, 1) };
2627

2728
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
2829
{
@@ -36,23 +37,23 @@ protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
3637

3738
public override ProcessingSourceInfo GetAboutInfo()
3839
{
39-
return new ProcessingSourceInfo()
40+
var info = ProcessingSourceInfoGenerator.GetEmpty();
41+
info.ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" };
42+
info.CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year;
43+
info.AdditionalInformation = new[]
4044
{
41-
ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" },
42-
CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year,
43-
AdditionalInformation = new[]
44-
{
45-
"Built using Antlr 4\n" +
46-
"Copyright (c) 2012 Terence Parr and Sam Harwell\n" +
47-
"All rights reserved.\n" +
48-
"Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n" +
49-
"\n" +
50-
"Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n" +
51-
"Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n" +
52-
"Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n" +
53-
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
54-
},
45+
"Built using Antlr 4\n" +
46+
"Copyright (c) 2012 Terence Parr and Sam Harwell\n" +
47+
"All rights reserved.\n" +
48+
"Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n" +
49+
"\n" +
50+
"Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n" +
51+
"Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n" +
52+
"Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n" +
53+
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
5554
};
55+
56+
return info;
5657
}
5758

5859
/// <inheritdoc />

PerfDataExtension/PerfDataExtension.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
</Compile>
6060
</ItemGroup>
6161

62+
<ItemGroup>
63+
<ProjectReference Include="..\Utilities\Utilities.csproj" />
64+
</ItemGroup>
65+
6266
<Target Name="CopyToTargetDirTarget" AfterTargets="Build">
6367
<Copy SourceFiles="@(CopyToTargetDir)" DestinationFolder="$(TargetDir)" />
6468
</Target>

PerfDataExtension/PerfDataProcessingSource.cs

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

4+
using Utilities;
5+
46
namespace Microsoft.Performance.Toolkit.Plugins.PerfDataExtension
57
{
68
using Microsoft.LinuxTracepoints.Decode;
@@ -21,13 +23,14 @@ public sealed class PerfDataProcessingSource
2123
{
2224
public override ProcessingSourceInfo GetAboutInfo()
2325
{
24-
return new ProcessingSourceInfo
25-
{
26-
CopyrightNotice = "Copyright (c) Microsoft Corporation. All rights reserved.",
27-
LicenseInfo = new LicenseInfo { Name = "MIT" },
28-
Owners = Array.Empty<ContactInfo>(),
29-
ProjectInfo = new ProjectInfo { Uri = "https://github.com/microsoft/LinuxTracepoints-Net" },
30-
};
26+
var info = ProcessingSourceInfoGenerator.GetEmpty();
27+
28+
info.CopyrightNotice = "Copyright (c) Microsoft Corporation. All rights reserved.";
29+
info.LicenseInfo = new LicenseInfo { Name = "MIT" };
30+
info.Owners = Array.Empty<ContactInfo>();
31+
info.ProjectInfo = new ProjectInfo { Uri = "https://github.com/microsoft/LinuxTracepoints-Net" };
32+
33+
return info;
3134
}
3235

3336
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)

PerfDataTxtExtension/SourceDataCookers/PerfDataProcessingSource.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Linq;
88
using Microsoft.Performance.SDK.Processing;
9+
using Utilities;
910

1011
namespace PerfDataProcessingSource
1112
{
@@ -44,10 +45,9 @@ public class PerfDataProcessingSource
4445

4546
public override ProcessingSourceInfo GetAboutInfo()
4647
{
47-
return new ProcessingSourceInfo()
48-
{
49-
ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" },
50-
};
48+
var info = ProcessingSourceInfoGenerator.GetEmpty();
49+
info.ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" };
50+
return info;
5151
}
5252

5353
protected override void SetApplicationEnvironmentCore(IApplicationEnvironment applicationEnvironment)

PerfettoCds/Pipeline/PerfettoDataSource.cs

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
using System.IO;
66
using System.Linq;
77
using Microsoft.Performance.SDK.Processing;
8+
using Utilities;
89

910
namespace PerfettoCds
1011
{
11-
public static class PerfettoCds
12-
{
13-
public static string[] PerfettoCopyrightLicense = new string[]
14-
{
12+
public static class PerfettoCds
13+
{
14+
public static string[] PerfettoCopyrightLicense = new string[]
15+
{
1516
"Built using Google Perfetto 4\n" +
1617
"Copyright (C) 2020 The Android Open Source Project\n" +
1718
"\n" +
@@ -25,8 +26,8 @@ public static class PerfettoCds
2526
"distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
2627
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
2728
"See the License for the specific language governing permissions and\n" +
28-
"limitations under the License.\n"
29-
};
29+
"limitations under the License.\n"
30+
};
3031
}
3132

3233
[ProcessingSource("9fc8515e-9206-4690-b14a-3e7b54745c5f", "PerfettoTraceDataSource", "Processes Perfetto trace files")]
@@ -47,12 +48,13 @@ protected override ICustomDataProcessor CreateProcessorCore(IEnumerable<IDataSou
4748

4849
public override ProcessingSourceInfo GetAboutInfo()
4950
{
50-
return new ProcessingSourceInfo()
51-
{
52-
ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" },
53-
CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year,
54-
AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense,
55-
};
51+
var info = ProcessingSourceInfoGenerator.GetEmpty();
52+
53+
info.ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" };
54+
info.CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year;
55+
info.AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense;
56+
57+
return info;
5658
}
5759

5860
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
@@ -91,12 +93,13 @@ protected override ICustomDataProcessor CreateProcessorCore(IEnumerable<IDataSou
9193

9294
public override ProcessingSourceInfo GetAboutInfo()
9395
{
94-
return new ProcessingSourceInfo()
95-
{
96-
ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" },
97-
CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year,
98-
AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense,
99-
};
96+
var info = ProcessingSourceInfoGenerator.GetEmpty();
97+
98+
info.ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" };
99+
info.CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year;
100+
info.AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense;
101+
102+
return info;
100103
}
101104

102105
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
@@ -135,12 +138,13 @@ protected override ICustomDataProcessor CreateProcessorCore(IEnumerable<IDataSou
135138

136139
public override ProcessingSourceInfo GetAboutInfo()
137140
{
138-
return new ProcessingSourceInfo()
139-
{
140-
ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" },
141-
CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year,
142-
AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense,
143-
};
141+
var info = ProcessingSourceInfoGenerator.GetEmpty();
142+
143+
info.ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" };
144+
info.CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year;
145+
info.AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense;
146+
147+
return info;
144148
}
145149

146150
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
@@ -179,12 +183,13 @@ protected override ICustomDataProcessor CreateProcessorCore(IEnumerable<IDataSou
179183

180184
public override ProcessingSourceInfo GetAboutInfo()
181185
{
182-
return new ProcessingSourceInfo()
183-
{
184-
ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" },
185-
CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year,
186-
AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense,
187-
};
186+
var info = ProcessingSourceInfoGenerator.GetEmpty();
187+
188+
info.ProjectInfo = new ProjectInfo() { Uri = "https://aka.ms/linuxperftools" };
189+
info.CopyrightNotice = "Copyright (C) " + DateTime.UtcNow.Year;
190+
info.AdditionalInformation = PerfettoCds.PerfettoCopyrightLicense;
191+
192+
return info;
188193
}
189194

190195
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using Microsoft.Performance.SDK.Processing;
6+
7+
namespace Utilities
8+
{
9+
public static class ProcessingSourceInfoGenerator
10+
{
11+
public static ProcessingSourceInfo GetEmpty()
12+
{
13+
return new ProcessingSourceInfo()
14+
{
15+
Owners = Array.Empty<ContactInfo>(),
16+
ProjectInfo = null,
17+
LicenseInfo = null,
18+
CopyrightNotice = null,
19+
AdditionalInformation = Array.Empty<string>(),
20+
};
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)