Skip to content

Commit 0f05d39

Browse files
authored
Merge pull request #199 from cqse/ts/44454_fix_locking_dlls
TS-44454 Fix locking DLLs, revert TS-31191
2 parents a8e82e5 + 7dfb428 commit 0f05d39

File tree

26 files changed

+159
-585
lines changed

26 files changed

+159
-585
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Please prefix each entry with one of:
66
- [documentation]
77

88
# Next Release
9+
- [fix] Removed feature to upload coverage to multiple Teamscale projects via embedded resources, as it unexpectedly locked DLL files
910

1011
# v25.08.0
1112
- [feature] Removed `--config-from-env` option from the Upload Daemon: now it defaults to the `COR_PROFILER_CONFIG` environment variable
@@ -21,7 +22,7 @@ Please prefix each entry with one of:
2122

2223
# v24.2.0
2324
- [fix] Log message when trace directory is not writable
24-
- [feature] Added support to upload coverage to multiple Teamscale projects with different revisions.
25+
- [feature] Added support to upload coverage to multiple Teamscale projects with different revisions.
2526

2627
# v23.6.0
2728
- [feature] Support for uploading to artifactory with the Teamscale default artifact storage schema.

Profiler/Profiler.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ProjectGuid>{CC51C2F0-D0F2-41D9-B1D2-5108C1D3B8E6}</ProjectGuid>
2323
<RootNamespace>Profiler</RootNamespace>
2424
<Keyword>Win32Proj</Keyword>
25-
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
25+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
2626
<PlatformToolset>v143</PlatformToolset>
2727
</PropertyGroup>
2828
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

TeamscaleEmbeddedResourceUpdater/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

TeamscaleEmbeddedResourceUpdater/TeamscaleResourceUpdate.ps1

Lines changed: 0 additions & 77 deletions
This file was deleted.

UploadDaemon/App.config

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
55
</startup>
66
<system.net>
77
<!-- By default, the upload daemon uses the system proxy settings.
@@ -24,8 +24,8 @@
2424
<runtime>
2525
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
2626
<dependentAssembly>
27-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
28-
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
27+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
28+
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
2929
</dependentAssembly>
3030
<dependentAssembly>
3131
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
@@ -50,12 +50,12 @@
5050
While this should usually not be necessary, in edge cases this may allow us to process amounts of
5151
coverage that could otherwise not be merged.
5252
-->
53-
<gcAllowVeryLargeObjects enabled="true" />
53+
<gcAllowVeryLargeObjects enabled="true"/>
5454
<!--
5555
Allow using SSLv3. Some people run really old stacks that don't support
5656
any modern protocols and .NET in newer versions disables SSLv3
5757
c.f. https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/mitigation-tls-protocols
5858
-->
59-
<AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=true" />
59+
<AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=true"/>
6060
</runtime>
6161
</configuration>

UploadDaemon/Configuration/Config.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.IO;
4-
using System.Linq;
2+
using System.Collections.Generic;
3+
using System;
54
using System.Text.RegularExpressions;
5+
using System.Linq;
66
using UploadDaemon.SymbolAnalysis;
77

88
namespace UploadDaemon.Configuration
@@ -182,6 +182,13 @@ public IEnumerable<string> Validate()
182182
@" without the file extension) to read the program version from in order to upload method coverage." +
183183
@" Alternatively, you can configure line coverage upload (properties ""pdbDirectory"" and ""revisionFile"").";
184184
}
185+
if (PdbDirectory != null && RevisionFile == null)
186+
{
187+
yield return $"Invalid configuration for process {ProcessPath}." +
188+
@" You provided a path to PDB files but no revision file (property ""revisionFile"")." +
189+
@" This file must contain the ID of the commit in your VCS from which the profiled code" +
190+
@" was built (e.g. for TFS: the changeset number, for Git: the SHA1) in the format `revision: COMMIT_ID`.";
191+
}
185192
}
186193
}
187194

@@ -283,6 +290,7 @@ public static Config ReadConfigFile(string configFilePath)
283290
throw new InvalidConfigException($"{e.Message}: The uploader will only watch for trace files in the targetdir" +
284291
$" directories configured in {configFilePath}");
285292
}
293+
286294
}
287295

288296
/// <summary>
@@ -313,6 +321,7 @@ private static bool SectionApplies(ConfigParser.ProcessSection section, string p
313321
MatchesLoadedAssemblyPathRegex(section, traceFile),
314322
};
315323

324+
316325
// The section applies if at least one of the check criteria is set (!= null) and all of these are true.
317326
return checks.Where(check => check != null).All(check => check == true);
318327
}

UploadDaemon/Configuration/TeamscaleServer.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,6 @@ public string Url
4343
/// </summary>
4444
public string Message { get; set; } = "Test coverage for version %v from %p created at %t";
4545

46-
public TeamscaleServer(string targetProject, TeamscaleServer other)
47-
{
48-
Url = other.Url;
49-
Project = targetProject;
50-
Partition = other.Partition;
51-
Username = other.Username;
52-
AccessKey = other.AccessKey;
53-
Message = other.Message;
54-
}
55-
56-
/// <summary>
57-
/// Needed only for automatic creation via yaml file.
58-
/// </summary>
59-
public TeamscaleServer()
60-
{
61-
// intentionally left blank.
62-
}
63-
6446
public override string ToString()
6547
{
6648
return $"Teamscale {Url} project {Project} with user {Username}, partition {Partition}";
@@ -76,6 +58,10 @@ public IEnumerable<string> Validate()
7658
{
7759
yield return @"You must provide a valid URL to connect to Teamscale";
7860
}
61+
if (Project == null)
62+
{
63+
yield return @"You must provide a project into which the coverage will be uploaded";
64+
}
7965
if (Username == null)
8066
{
8167
yield return @"You must provide a username to connect to Teamscale";

UploadDaemon/SymbolAnalysis/ParsedTraceFile.cs

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using System.Reflection;
6-
using System.Resources;
75
using System.Text.RegularExpressions;
8-
using static UploadDaemon.SymbolAnalysis.RevisionFileUtils;
96

107
namespace UploadDaemon.SymbolAnalysis
118
{
@@ -36,16 +33,6 @@ public class ParsedTraceFile
3633
private static readonly Regex AssemblyLineRegex = new Regex(@"^Assembly=(?<name>[^:]+):(?<id>\d+).*?(?: Path:(?<path>.*))?$");
3734
private static readonly Regex CoverageLineRegex = new Regex(@"^(?:Inlined|Jitted)=(\d+):(?:\d+:)?(\d+)");
3835

39-
/// <summary>
40-
/// The name of the Resource .resx file that holed information about embedded upload targets.
41-
/// </summary>
42-
private const String TeamscaleResourceName = "Teamscale";
43-
44-
/// <summary>
45-
/// The uploads targets (revision/timestamp and optionally teamscale project) that are retrieved from resource files that are embedded into assemblies referenced in the trace file.
46-
/// </summary>
47-
public readonly List<(string project, RevisionOrTimestamp revisionOrTimestamp)> embeddedUploadTargets = new List<(string project, RevisionOrTimestamp revisionOrTimestamp)>();
48-
4936
public ParsedTraceFile(string[] lines, string filePath)
5037
{
5138
this.FilePath = filePath;
@@ -57,7 +44,7 @@ public ParsedTraceFile(string[] lines, string filePath)
5744
match => (name: match.Groups["name"].Value, path: match.Groups["path"].Value)
5845
);
5946
this.LoadedAssemblies = assemblyTokens.Values.ToList();
60-
SearchForEmbeddedUploadTargets();
47+
6148
IEnumerable<Match> coverageMatches = lines.Select(line => CoverageLineRegex.Match(line))
6249
.Where(match => match.Success);
6350
foreach (Match match in coverageMatches)
@@ -72,88 +59,5 @@ public ParsedTraceFile(string[] lines, string filePath)
7259
CoveredMethods.Add((assembly.name, Convert.ToUInt32(match.Groups[2].Value)));
7360
}
7461
}
75-
76-
/// <summary>
77-
/// Checks the loaded assemblies for resources that contain information about target revision or teamscale projects.
78-
/// </summary>
79-
private void SearchForEmbeddedUploadTargets()
80-
{
81-
foreach ((_, string path) in this.LoadedAssemblies)
82-
{
83-
Assembly assembly = LoadAssemblyFromPath(path);
84-
if (assembly == null || assembly.DefinedTypes == null)
85-
{
86-
continue;
87-
}
88-
TypeInfo teamscaleResourceType = assembly.DefinedTypes.FirstOrDefault(x => x.Name == TeamscaleResourceName) ?? null;
89-
if (teamscaleResourceType == null)
90-
{
91-
continue;
92-
}
93-
logger.Info("Found embedded Teamscale resource in {assembly} that can be used to identify upload targets.", assembly);
94-
ResourceManager teamscaleResourceManager = new ResourceManager(teamscaleResourceType.FullName, assembly);
95-
string embeddedTeamscaleProject = teamscaleResourceManager.GetString("Project");
96-
string embeddedRevision = teamscaleResourceManager.GetString("Revision");
97-
string embeddedTimestamp = teamscaleResourceManager.GetString("Timestamp");
98-
AddUploadTarget(embeddedRevision, embeddedTimestamp, embeddedTeamscaleProject, embeddedUploadTargets, assembly.FullName);
99-
}
100-
}
101-
102-
/// <summary>
103-
/// Adds a revision or timestamp and optionally a project to the list of upload targets. This method checks if both, revision and timestamp, are declared, or neither.
104-
/// </summary>
105-
/// <param name="revision"></param>
106-
/// <param name="timestamp"></param>
107-
/// <param name="project"></param>
108-
/// <param name="uploadTargets"></param>
109-
/// <param name="origin"></param>
110-
public static void AddUploadTarget(string revision, string timestamp, string project, List<(string project, RevisionOrTimestamp revisionOrTimestamp)> uploadTargets, string origin)
111-
{
112-
Logger logger = LogManager.GetCurrentClassLogger();
113-
114-
if (revision == null && timestamp == null)
115-
{
116-
logger.Error("Not all required fields in {origin}. Please specify either 'Revision' or 'Timestamp'", origin);
117-
return;
118-
}
119-
if (revision != null && timestamp != null)
120-
{
121-
logger.Error("'Revision' and 'Timestamp' are both set in {origin}. Please set only one, not both.", origin);
122-
return;
123-
}
124-
if (revision != null)
125-
{
126-
uploadTargets.Add((project, new RevisionOrTimestamp(revision, true)));
127-
}
128-
else
129-
{
130-
uploadTargets.Add((project, new RevisionOrTimestamp(timestamp, false)));
131-
}
132-
}
133-
134-
private Assembly LoadAssemblyFromPath(string path)
135-
{
136-
if (String.IsNullOrEmpty(path))
137-
{
138-
return null;
139-
}
140-
Assembly assembly;
141-
try
142-
{
143-
assembly = Assembly.LoadFrom(path);
144-
// Check that defined types can actually be loaded
145-
if (assembly == null)
146-
{
147-
return null;
148-
}
149-
IEnumerable<TypeInfo> ignored = assembly.DefinedTypes;
150-
}
151-
catch (Exception e)
152-
{
153-
logger.Debug("Could not load {assembly}. Skipping upload resource discovery. {e}", path, e);
154-
return null;
155-
}
156-
return assembly;
157-
}
15862
}
159-
}
63+
}

UploadDaemon/SymbolAnalysis/RevisionFileUtils.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ public class RevisionFileUtils
1616
/// </summary>
1717
public class RevisionOrTimestamp
1818
{
19-
public RevisionOrTimestamp(string value, bool isRevision)
20-
{
21-
this.Value = value;
22-
this.IsRevision = isRevision;
23-
}
24-
2519
/// <summary>
2620
/// The timestamp or revision.
2721
/// </summary>
@@ -72,15 +66,23 @@ public static RevisionOrTimestamp Parse(string[] revisionFileLines, string fileP
7266
" found neither a timestamp nor a revision entry." +
7367
" Examples: 'timestamp: 1234567890' or 'revision: 123456'");
7468
}
75-
(string type, string value) = matches.First();
7669

70+
(string type, string value) = matches.First();
7771
switch (type.ToLower())
7872
{
7973
case "timestamp":
80-
return new RevisionOrTimestamp(value, false);
74+
return new RevisionOrTimestamp
75+
{
76+
Value = value,
77+
IsRevision = false,
78+
};
8179

8280
case "revision":
83-
return new RevisionOrTimestamp(value, true);
81+
return new RevisionOrTimestamp
82+
{
83+
Value = value,
84+
IsRevision = true,
85+
};
8486

8587
default:
8688
throw new InvalidRevisionFileException($"The revision file {filePath} is not valid:" +

0 commit comments

Comments
 (0)