Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable single file analyzer in the runtime #50894

Merged
merged 32 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
937f893
Enable single file analyzer in the runtime
Apr 8, 2021
1b3dc8e
Merge branch 'main' into SingleFileAnalyzerOnRuntime
tlakollo Apr 8, 2021
f839417
Add IL3002 to CodeAnalysis.test.ruleset to avoid warning on tests
Apr 9, 2021
f92327e
Merge branch 'SingleFileAnalyzerOnRuntime' of https://github.com/tlak…
Apr 9, 2021
ae1bd07
Fix formating of CustomAttribute
Apr 9, 2021
23828b9
Fix introduced typo
Apr 9, 2021
9ec8520
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
Apr 9, 2021
eba095e
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
Apr 12, 2021
67dbd63
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
Apr 14, 2021
63a395a
Fix some formatting/comments/extra pragma
Apr 14, 2021
91ecb47
Fix UnconditionalSuppressMessage when TFM != NetCoreAppCurrent
Apr 14, 2021
eb6d83a
Add more UnconditionalSuppressMessage support for TFM !=
Apr 14, 2021
4bfc9a8
Fix incompatibility in EventLog.csproj
Apr 14, 2021
6367cb9
Add System.Diagnostics.Tools if TFM is netcoreapp3.0 on
Apr 14, 2021
6bad341
Address some PR comments
Apr 16, 2021
0597dde
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
Apr 26, 2021
4786f73
Change code in DependencyContext to not use Lazy
Apr 27, 2021
33f6916
PR feedback
Apr 28, 2021
b232294
Redo changes in MetadataLoadContext.csproj after checking out the main
Apr 28, 2021
2947adb
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
Apr 28, 2021
f120ae9
Delete extra code
Apr 28, 2021
874f872
Disable SingleFileAnalyzer for Microsoft.XmlSerializer.Generator and
Apr 28, 2021
1debcce
Merge branch 'main' into SingleFileAnalyzerOnRuntime
tlakollo Apr 29, 2021
870dc92
Missing message change
Apr 29, 2021
670bdcb
Merge branch 'SingleFileAnalyzerOnRuntime' of https://github.com/tlak…
Apr 29, 2021
dbb0690
PR feedback
tlakollo Apr 29, 2021
0994fec
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
tlakollo May 12, 2021
2d47bad
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
tlakollo May 12, 2021
df3c4bd
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
tlakollo May 14, 2021
c2dc595
Change UnconditionalSuppressMessage for SuppressMessage since SingleFile
tlakollo May 14, 2021
ff7f84f
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
tlakollo May 17, 2021
305b675
Merge branch 'main' of https://github.com/dotnet/runtime into SingleF…
tlakollo May 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eng/Analyzers.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<CodeAnalysisRuleset>$(MSBuildThisFileDirectory)CodeAnalysis.ruleset</CodeAnalysisRuleset>
<!-- Disable analyzers in sourcebuild -->
<RunAnalyzers Condition="'$(DotNetBuildFromSource)' == 'true'">false</RunAnalyzers>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
</PropertyGroup>
<ItemGroup Condition="'$(RunAnalyzers)' != 'false'">
<PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="$(StyleCopAnalyzersVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.ILLink.Analyzers" Version="$(MicrosoftNETILLinkAnalyzerPackageVersion)" PrivateAssets="all" />
</ItemGroup>
</Project>
2 changes: 0 additions & 2 deletions eng/CodeAnalysis.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@
<Rule Id="CA5401" Action="None" /> <!-- Do not use CreateEncryptor with non-default IV -->
<Rule Id="CA5402" Action="None" /> <!-- Use CreateEncryptor with the default IV -->
<Rule Id="CA5403" Action="None" /> <!-- Do not hard-code certificate -->
<Rule Id="IL3000" Action="None" /> <!-- Avoid using accessing Assembly file path when publishing as a single-file -->
<Rule Id="IL3001" Action="None" /> <!-- Avoid using accessing Assembly file path when publishing as a single-file -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="AD0001" Action="None" /> <!-- Analyzer threw an exception -->
Expand Down
1 change: 1 addition & 0 deletions eng/CodeAnalysis.test.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
<Rule Id="CA5403" Action="None" /> <!-- Do not hard-code certificate -->
<Rule Id="IL3000" Action="None" /> <!-- Avoid using accessing Assembly file path when publishing as a single-file -->
<Rule Id="IL3001" Action="None" /> <!-- Avoid using accessing Assembly file path when publishing as a single-file -->
<Rule Id="IL3002" Action="None" /> <!-- Using member with RequiresAssemblyFilesAttribute can break functionality when embedded in a single-file app -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="AD0001" Action="None" /> <!-- Analyzer threw an exception -->
Expand Down
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
<MicrosoftPrivateIntellisenseVersion>5.0.0-preview-20201009.2</MicrosoftPrivateIntellisenseVersion>
<!-- ILLink -->
<MicrosoftNETILLinkTasksVersion>6.0.100-preview.2.21226.1</MicrosoftNETILLinkTasksVersion>
<MicrosoftNETILLinkAnalyzerPackageVersion>$(MicrosoftNETILLinkTasksVersion)</MicrosoftNETILLinkAnalyzerPackageVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-preview.5.21226.1</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- Mono LLVM -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;

namespace Microsoft.Extensions.DependencyModel
{
public class DependencyContext
{

[UnconditionalSuppressMessage("SingleFile", "IL3002:Avoid calling members marked with 'RequiresAssemblyFilesAttribute' when publishing as a single-file",
Justification = "The annotation should be on the static constructor but is Compiler Generated, annotating the caller Default method instead")]
private static readonly Lazy<DependencyContext> _defaultContext = new Lazy<DependencyContext>(LoadDefault);
tlakollo marked this conversation as resolved.
Show resolved Hide resolved

public DependencyContext(TargetInfo target,
Expand Down Expand Up @@ -46,6 +50,7 @@ public DependencyContext(TargetInfo target,
RuntimeGraph = runtimeGraph.ToArray();
}

[RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")]
public static DependencyContext Default => _defaultContext.Value;

public TargetInfo Target { get; }
Expand Down Expand Up @@ -74,6 +79,7 @@ public DependencyContext Merge(DependencyContext other)
);
}

[RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")]
private static DependencyContext LoadDefault()
{
var entryAssembly = Assembly.GetEntryAssembly();
Expand All @@ -85,6 +91,7 @@ private static DependencyContext LoadDefault()
return Load(entryAssembly);
}

[RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")]
public static DependencyContext Load(Assembly assembly)
{
return DependencyContextLoader.Default.Load(assembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;

Expand Down Expand Up @@ -50,6 +51,7 @@ private static Stream GetResourceStream(Assembly assembly, string name)
return assembly.GetManifestResourceStream(name);
}

[RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")]
public DependencyContext Load(Assembly assembly)
{
if (assembly == null)
Expand Down Expand Up @@ -103,6 +105,7 @@ private DependencyContext LoadContext(IDependencyContextReader reader, string lo
return null;
}

[RequiresAssemblyFiles(Message = "DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.")]
private DependencyContext LoadAssemblyContext(Assembly assembly, IDependencyContextReader reader)
{
using (Stream stream = GetResourceStream(assembly, assembly.GetName().Name + DepsJsonExtension))
Expand All @@ -125,6 +128,7 @@ private DependencyContext LoadAssemblyContext(Assembly assembly, IDependencyCont
return null;
}

[RequiresAssemblyFiles(Message = "The use of DependencyContextLoader is not supported when publishing as single-file")]
private string GetDepsJsonPath(Assembly assembly)
{
// Assemblies loaded in memory (e.g. single file) return empty string from Location.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<EnableDefaultItems>true</EnableDefaultItems>
Expand All @@ -7,6 +7,8 @@
<ItemGroup>
<Compile Include="$(CoreLibSharedDir)\System\Numerics\Hashing\HashHelpers.cs"
Link="System\Numerics\Hashing\HashHelpers.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresAssemblyFilesAttribute.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
</ItemGroup>

<ItemGroup>
Expand All @@ -25,4 +27,5 @@
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Encodings.Web\src\System.Text.Encodings.Web.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\src\System.Text.Json.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;

Expand All @@ -27,6 +28,8 @@ public static void Enable()
// has run.
}

[UnconditionalSuppressMessage("SingleFile", "IL3000:Avoid accessing Assembly file path when publishing as a single file",
Justification = "The code has a fallback to use AppDomain.CurrentDomain.BaseDirectory so it will work correctly in single-file")]
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
// apply any existing policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Compile Include="BuildTask.Desktop.cs" />
<Compile Include="AssemblyResolver.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
</ItemGroup>

<ItemGroup>
Expand All @@ -37,7 +38,7 @@
<Content Condition="'$(AdditionalRuntimeIdentifiers)' != ''" Include="$(IntermediateOutputPath)runtime.json" PackagePath="/" />
<Content Include="_._" PackagePath="lib/netstandard1.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="$(RefOnlyMicrosoftBuildVersion)" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(RefOnlyMicrosoftBuildTasksCoreVersion)" />
Expand All @@ -54,4 +55,4 @@
</Target>

<Import Project="runtimeGroups.props" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
<StringResourcesName>FxResources.$(AssemblyName.Replace('-', '_')).SR</StringResourcesName>
<OutputType>Exe</OutputType>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer>
</PropertyGroup>

tlakollo marked this conversation as resolved.
Show resolved Hide resolved
<ItemGroup>
<Compile Include="Sgen.cs" />
</ItemGroup>

<Import Project=".\GenerateThisAssemblyCs.targets" />
</Project>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@
<Compile Include="$(CommonPath)System\Composition\Diagnostics\TraceWriter.cs"
Link="Common\System\Composition\Diagnostics\TraceWriter.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Reference Include="Microsoft.Win32.Primitives" />
<Reference Include="System.Collections" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ private void ThrowIfDisposed()
private string GetDisplayName() =>
$"{GetType().Name} (Assembly=\"{Assembly.FullName}\")"; // NOLOC

[UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file",
Justification = "Setting a CodeBase is single file compatible")]
private static Assembly LoadAssembly(string codeBase)
{
Requires.NotNullOrEmpty(codeBase, nameof(codeBase));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Collections;
Expand Down Expand Up @@ -57,6 +58,8 @@ private string GetLocalPath(string fileName)
return uri.LocalPath + uri.Fragment;
}

[UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file",
Justification = "Suppressing the warning until gets fixed, see https://github.com/dotnet/runtime/issues/50821")]
public override string GetSavedLicenseKey(Type type, Assembly resourceAssembly)
{
if (_savedLicenseKeys == null || _savedLicenseKeys[type.AssemblyQualifiedName] == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
<Compile Include="System\UriIdnScope.cs" />
<Compile Include="$(CommonPath)System\IO\TempFileCollection.cs"
Link="Common\System\IO\TempFileCollection.cs" />
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
</ItemGroup>
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.Cryptography.ProtectedData\src\System.Security.Cryptography.ProtectedData.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Reflection;
Expand All @@ -28,6 +29,8 @@ internal sealed class ClientConfigPaths
private readonly bool _includesUserConfig;
private string _companyName;

[UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file",
Justification = "Code handles single file case")]
private ClientConfigPaths(string exePath, bool includeUserConfig)
{
_includesUserConfig = includeUserConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Win32.Registry\src\Microsoft.Win32.Registry.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Threading.AccessControl\src\System.Threading.AccessControl.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)-windows'">
tlakollo marked this conversation as resolved.
Show resolved Hide resolved
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
</ItemGroup>

<!-- Ensure we run ResolveProjectReferences to add the message DLL to the package.
We do this here rather than in the pkgproj to ensure the package paths are in sync -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -691,6 +692,8 @@ internal static RegistryKey GetEventLogRegKey(string machine, bool writable)
return null;
}

[UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file",
Justification = "The code handles if the path is null by calling AppContext.BaseDirectory")]
internal static string GetDllPath(string machineName)
{
string dllPath = Path.Combine(NetFrameworkUtils.GetLatestBuildDllDirectory(machineName), DllName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;

namespace System
{
public static partial class AppContext
{
[UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file",
Justification = "Single File apps should always set APP_CONTEXT_BASE_DIRECTORY therefore code handles Assembly.Location equals null")]
private static string GetBaseDirectoryCore()
{
// Fallback path for hosts that do not set APP_CONTEXT_BASE_DIRECTORY explicitly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ namespace System.Diagnostics.CodeAnalysis
AttributeTargets.Property,
Inherited = false,
AllowMultiple = false)]
public sealed class RequiresAssemblyFilesAttribute : Attribute
#if SYSTEM_PRIVATE_CORELIB
public
#else
internal
#endif
sealed class RequiresAssemblyFilesAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="RequiresAssemblyFilesAttribute"/> class.
Expand All @@ -32,4 +37,4 @@ public RequiresAssemblyFilesAttribute() { }
/// </summary>
public string? Url { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public virtual IEnumerable<Type> ExportedTypes
[RequiresUnreferencedCode("Types might be removed")]
public virtual Type[] GetForwardedTypes() { throw NotImplemented.ByDesign; }

[RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")]
public virtual string? CodeBase => throw NotImplemented.ByDesign;
public virtual MethodInfo? EntryPoint => throw NotImplemented.ByDesign;
public virtual string? FullName => throw NotImplemented.ByDesign;
Expand Down Expand Up @@ -115,6 +116,7 @@ public virtual IEnumerable<Type> ExportedTypes
public virtual object[] GetCustomAttributes(bool inherit) { throw NotImplemented.ByDesign; }
public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) { throw NotImplemented.ByDesign; }

[RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")]
public virtual string EscapedCodeBase => AssemblyName.EscapeCodeBase(CodeBase);

[RequiresUnreferencedCode("Assembly.CreateInstance is not supported with trimming. Use Type.GetType instead.")]
Expand Down Expand Up @@ -152,6 +154,7 @@ public virtual IEnumerable<Type> ExportedTypes
public virtual Assembly GetSatelliteAssembly(CultureInfo culture, Version? version) { throw NotImplemented.ByDesign; }

public virtual FileStream? GetFile(string name) { throw NotImplemented.ByDesign; }
[RequiresAssemblyFiles(Message = "The code will throw for assemblies embedded in a single-file app")]
public virtual FileStream[] GetFiles() => GetFiles(getResourceModules: false);
public virtual FileStream[] GetFiles(bool getResourceModules) { throw NotImplemented.ByDesign; }

Expand Down Expand Up @@ -268,6 +271,8 @@ public static Assembly LoadFile(string path)
}

[RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
[UnconditionalSuppressMessage("SingleFile", "IL3000:Avoid accessing Assembly file path when publishing as a single file",
Justification = "The assembly is loaded by specifying a path outside of the single-file bundle, the location of the path will not be empty if the path exist, otherwise it will be handled as null")]
private static Assembly? LoadFromResolveHandler(object? sender, ResolveEventArgs args)
{
Assembly? requestingAssembly = args.RequestingAssembly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Configuration.Assemblies;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Text;
using CultureInfo = System.Globalization.CultureInfo;
Expand Down Expand Up @@ -59,10 +60,12 @@ public string? CultureName

public string? CodeBase
{
[RequiresAssemblyFiles(Message = "The code will return an empty string for assemblies embedded in a single-file app")]
get => _codeBase;
set => _codeBase = value;
}

[RequiresAssemblyFiles(Message = "The code will return an empty string for assemblies embedded in a single-file app")]
public string? EscapedCodeBase
{
get
Expand Down Expand Up @@ -260,6 +263,7 @@ public static bool ReferenceMatchesDefinition(AssemblyName? reference, AssemblyN
return refName.Equals(defName, StringComparison.OrdinalIgnoreCase);
}

[RequiresAssemblyFiles(Message = "The code will return an empty string for assemblies embedded in a single-file app")]
internal static string EscapeCodeBase(string? codebase)
{
if (codebase == null)
Expand Down
Loading