Skip to content

Commit

Permalink
TS-31191 update docs and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jveihelmann committed Dec 8, 2023
1 parent ab57ba1 commit bae15bb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
20 changes: 14 additions & 6 deletions TeamscaleEmbeddedResourceUpdater/TeamscaleResourceUpdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ function Update-ResxFile {
$dataNode.InnerXml = "<value>$value</value>"

# Add or update the 'Project' property
$projectNode = $resxXml.SelectSingleNode("/root/data[@name='Project']")
if ($projectNode -eq $null) {
$projectNode = $resxXml.CreateElement("data")
$projectNode.SetAttribute("name", 'Project')
$rootNode.AppendChild($projectNode)
if ($project -ne $null) {

$projectNode = $resxXml.SelectSingleNode("/root/data[@name='Project']")
if ($projectNode -eq $null) {
$projectNode = $resxXml.CreateElement("data")
$projectNode.SetAttribute("name", 'Project')
$rootNode.AppendChild($projectNode)
}
$projectNode.InnerXml = "<value>$project</value>"
}

# Write updated content back to .resx file
$resxXml.Save($resxPath)
}
Expand All @@ -65,5 +69,9 @@ if ($revision) {

# Update the .resx file
Update-ResxFile -resxPath $path -key $key -value $value -project $project
Write-Host "Updated Teamscale Resource with $($key): $($value) and $($project)"
if ($project -eq $null){
Write-Host "Updated Teamscale Resource with $($key): $($value)"
} else {
Write-Host "Updated Teamscale Resource with $($key): $($value) and $($project)"
}

8 changes: 6 additions & 2 deletions UploadDaemon/SymbolAnalysis/ParsedTraceFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ private void SearchForEmbeddedUploadTargets()
foreach ((_, string path) in this.LoadedAssemblies)
{
Assembly assembly = LoadAssemblyFromPath(path);
if (assembly == null || assembly.DefinedTypes == null)
IEnumerable<TypeInfo> definedTypes = assembly.DefinedTypes;
if(assembly == null || definedTypes == null)
{
continue;
}
TypeInfo teamscaleResourceType = assembly.DefinedTypes.FirstOrDefault(x => x.Name == TeamscaleResourceName) ?? null;
TypeInfo teamscaleResourceType = definedTypes.FirstOrDefault(x => x.Name == TeamscaleResourceName) ?? null;
if (teamscaleResourceType == null)
{
continue;
Expand Down Expand Up @@ -141,10 +142,13 @@ private Assembly LoadAssemblyFromPath(string path)
try
{
assembly = Assembly.LoadFrom(path);
// Check that defined types can actually be loaded (this is implicetly a null check as well)
IEnumerable<TypeInfo> definedTypes = assembly.DefinedTypes;
}
catch (Exception e)
{
logger.Warn("Could not load {assembly}. Skipping upload resource discovery. {e}", path, e);
return null;
}
return assembly;
}
Expand Down
2 changes: 1 addition & 1 deletion UploadDaemon/Upload/MessageFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public string Format(string assemblyVersion)
public string Format(RevisionFileUtils.RevisionOrTimestamp revision)
{
string formattedTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
return server.Message.Replace("version %v", revision.GetType() + " " + revision.Value).Replace("%p", server.Partition).Replace("%t", formattedTime);
return server.Message.Replace("version %v", revision.ToRevisionFileContent()).Replace("%p", server.Partition).Replace("%t", formattedTime);
}
}
}
2 changes: 1 addition & 1 deletion documentation/userguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ This is an example how to integrate it into an Azure DevOps Pipeline:
displayName: 'Update Teamscale Resource'
workingDirectory: $(Build.Repository.LocalPath)

**_Note:_** The Teamscale Resource can work in combination with a revision file. So you can create a resource for your libraries and add a revision/uploadTarget file for your "main" application.
**_Note:_** The Teamscale Resource can work in combination with a revision file. So you can create a resource for your libraries and add a revision file for your "main" application.

Finally, please configure sensible `assemblyPatterns` in order to only include your application's
assemblies in the coverage analysis. This prevents lots of useless error log entries both in the
Expand Down

0 comments on commit bae15bb

Please sign in to comment.