Skip to content

Fix NRT warnings in assembly-store-reader-mk2 and decompress-assemblies tools. #10051

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

Merged
merged 1 commit into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@

This can be opted into locally with $(_AndroidTreatWarningsAsErrors) = true.
-->
<_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'assembly-store-reader.csproj' ">true</_AllowProjectWarnings>
<_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'decompress-assemblies.csproj' ">true</_AllowProjectWarnings>
<_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'jnienv-gen.csproj' ">true</_AllowProjectWarnings>
<_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Microsoft.Android.Sdk.ILLink.csproj' ">true</_AllowProjectWarnings>
<_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Microsoft.Android.Templates.csproj' ">true</_AllowProjectWarnings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void AddNativeLibraries (ArchiveFileList files, string [] supportedAbis)
}

foreach (string abi in supportedAbis) {
string clangAbi = MonoAndroidHelper.MapAndroidAbiToClang (abi);
string? clangAbi = MonoAndroidHelper.MapAndroidAbiToClang (abi);
if (string.IsNullOrEmpty (clangAbi)) {
LogSanitizerError ($"Unable to map Android ABI {abi} to clang ABI");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static AndroidTargetArch AbiToTargetArch (string abi)

public static string AbiToRid (string abi)
{
if (!AbiToRidMap.TryGetValue (abi, out string rid)) {
if (!AbiToRidMap.TryGetValue (abi, out string? rid)) {
throw new NotSupportedException ($"Internal error: unsupported ABI '{abi}'");
};

Expand All @@ -104,7 +104,7 @@ public static string AbiToRid (string abi)

public static string RidToAbi (string rid)
{
if (!RidToAbiMap.TryGetValue (rid, out string abi)) {
if (!RidToAbiMap.TryGetValue (rid, out string? abi)) {
throw new NotSupportedException ($"Internal error: unsupported Runtime Identifier '{rid}'");
};

Expand Down Expand Up @@ -132,7 +132,7 @@ public static AndroidTargetArch RidToArch (string rid)

public static string ArchToRid (AndroidTargetArch arch)
{
if (!ArchToRidMap.TryGetValue (arch, out string rid)) {
if (!ArchToRidMap.TryGetValue (arch, out string? rid)) {
throw new InvalidOperationException ($"Internal error: unsupported architecture '{arch}'");
};

Expand All @@ -141,7 +141,7 @@ public static string ArchToRid (AndroidTargetArch arch)

public static string ArchToAbi (AndroidTargetArch arch)
{
if (!ArchToAbiMap.TryGetValue (arch, out string abi)) {
if (!ArchToAbiMap.TryGetValue (arch, out string? abi)) {
throw new InvalidOperationException ($"Internal error: unsupported architecture '{arch}'");
};

Expand All @@ -160,9 +160,9 @@ public static string ArchToAbi (AndroidTargetArch arch)
return Convert.ToString (obj, CultureInfo.InvariantCulture);
}

public static string MapAndroidAbiToClang (string androidAbi)
public static string? MapAndroidAbiToClang (string androidAbi)
{
if (ClangAbiMap.TryGetValue (androidAbi, out string clangAbi)) {
if (ClangAbiMap.TryGetValue (androidAbi, out string? clangAbi)) {
return clangAbi;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected AssemblyStoreExplorer (Stream storeStream, string path)
Is64Bit = reader.Is64Bit;

var dict = new Dictionary<string, AssemblyStoreItem> (StringComparer.Ordinal);
foreach (AssemblyStoreItem item in Assemblies) {
foreach (AssemblyStoreItem item in Assemblies ?? []) {
dict.Add (item.Name, item);
}
AssembliesByName = dict.AsReadOnly ();
Expand Down
2 changes: 1 addition & 1 deletion tools/decompress-assemblies/main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static bool UncompressDLL (Stream inputStream, string fileName, string filePath,
Console.Error.WriteLine ($" Failed to decompress LZ4 data of {fileName} (decoded: {decoded})");
retVal = false;
} else {
string outputDir = Path.GetDirectoryName (outputFile);
string? outputDir = Path.GetDirectoryName (outputFile);
if (!String.IsNullOrEmpty (outputDir)) {
Directory.CreateDirectory (outputDir);
}
Expand Down
Loading