Skip to content

Commit

Permalink
Merge pull request #891 from SteeltoeOSS/backport_to_3.2
Browse files Browse the repository at this point in the history
Backport 869, 880, 881, 892 and file-scoped namespaces to 3.2
  • Loading branch information
TimHess authored Jul 27, 2022
2 parents bc267da + d47b80e commit a65adbc
Show file tree
Hide file tree
Showing 2,776 changed files with 227,083 additions and 229,709 deletions.
2 changes: 2 additions & 0 deletions Steeltoe.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@
<Rule Id="S3254" Action="None" />
<Rule Id="S3256" Action="Warning" />
<Rule Id="S3257" Action="None" />
<Rule Id="S3260" Action="None" />
<Rule Id="S3261" Action="Warning" />
<Rule Id="S3262" Action="Warning" />
<Rule Id="S3263" Action="Warning" />
<Rule Id="S3264" Action="Warning" />
<Rule Id="S3265" Action="Warning" />
<Rule Id="S3267" Action="None" />
<Rule Id="S3330" Action="Warning" />
<Rule Id="S3343" Action="Warning" />
<Rule Id="S3346" Action="Warning" />
Expand Down
1 change: 1 addition & 0 deletions build/circuitbreaker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/connectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/discovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/messaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
1 change: 1 addition & 0 deletions build/stream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pr:
branches:
include:
- main
- release/3.*
paths:
exclude:
- /
Expand Down
73 changes: 36 additions & 37 deletions src/Bootstrap/src/Autoconfig/AssemblyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,51 @@
using System.Reflection;
using System.Text.RegularExpressions;

namespace Steeltoe.Bootstrap.Autoconfig
namespace Steeltoe.Bootstrap.Autoconfig;

internal static class AssemblyExtensions
{
internal static class AssemblyExtensions
{
internal static IEnumerable<string> ExcludedAssemblies { get; set; }
internal static IEnumerable<string> ExcludedAssemblies { get; set; }

private static readonly HashSet<string> _missingAssemblies = new ();

private static readonly HashSet<string> _missingAssemblies = new ();
internal static Assembly LoadAnyVersion(object sender, ResolveEventArgs args)
{
// Load whatever version available - strip out version and culture info
static string GetSimpleName(string assemblyName) => new Regex(",.*").Replace(assemblyName, string.Empty);
var name = GetSimpleName(args.Name);
if (_missingAssemblies.Contains(name))
{
return null;
}

internal static Assembly LoadAnyVersion(object sender, ResolveEventArgs args)
var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToDictionary(x => x.GetName().Name, x => x);
if (assemblies.TryGetValue(name, out var assembly))
{
// Load whatever version available - strip out version and culture info
static string GetSimpleName(string assemblyName) => new Regex(",.*").Replace(assemblyName, string.Empty);
var name = GetSimpleName(args.Name);
if (_missingAssemblies.Contains(name))
{
return null;
}

var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToDictionary(x => x.GetName().Name, x => x);
if (assemblies.TryGetValue(name, out var assembly))
{
return assembly;
}

if (args.Name?.Contains(".resources") ?? false)
{
return args.RequestingAssembly;
}

_missingAssemblies.Add(name); // throw it in there to prevent recursive attempts to resolve
assembly = Assembly.Load(name);
_missingAssemblies.Remove(name);
return assembly;
}

internal static bool IsAssemblyLoaded(string assemblyName)
if (args.Name?.Contains(".resources") ?? false)
{
if (ExcludedAssemblies.Contains(assemblyName))
{
return false;
}
return args.RequestingAssembly;
}

_missingAssemblies.Add(name); // throw it in there to prevent recursive attempts to resolve
assembly = Assembly.Load(name);
_missingAssemblies.Remove(name);
return assembly;
}

return ReflectionHelpers.IsAssemblyLoaded(assemblyName);
internal static bool IsAssemblyLoaded(string assemblyName)
{
if (ExcludedAssemblies.Contains(assemblyName))
{
return false;
}

internal static bool IsEitherAssemblyLoaded(string assemblyName1, string assemblyName2) =>
IsAssemblyLoaded(assemblyName1) || IsAssemblyLoaded(assemblyName2);
return ReflectionHelpers.IsAssemblyLoaded(assemblyName);
}
}

internal static bool IsEitherAssemblyLoaded(string assemblyName1, string assemblyName2) =>
IsAssemblyLoaded(assemblyName1) || IsAssemblyLoaded(assemblyName2);
}
21 changes: 10 additions & 11 deletions src/Bootstrap/src/Autoconfig/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
using Steeltoe.Management.OpenTelemetry.Exporters.Wavefront;
using System;

namespace Steeltoe.Bootstrap.Autoconfig
namespace Steeltoe.Bootstrap.Autoconfig;

internal static class ConfigurationExtensions
{
internal static class ConfigurationExtensions
public static bool HasWavefront(this IConfiguration configuration)
{
public static bool HasWavefront(this IConfiguration configuration)
if (configuration == null)
{
if (configuration == null)
{
throw new ArgumentNullException(nameof(configuration));
}

var options = new WavefrontExporterOptions(configuration);
return !string.IsNullOrEmpty(options.Uri);
throw new ArgumentNullException(nameof(configuration));
}

var options = new WavefrontExporterOptions(configuration);
return !string.IsNullOrEmpty(options.Uri);
}
}
}
Loading

0 comments on commit a65adbc

Please sign in to comment.