Skip to content

Commit bcc818f

Browse files
authored
[wasm] Add warning code to all warnings produced in WasmAppBuilder (#78755)
* Add WASM000x warning code to all warning produced in WasmAppBuilder. * Feedback from @radical. * Fix analyzer.
1 parent 1abc433 commit bcc818f

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

src/tasks/WasmAppBuilder/EmccCompile.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ ITaskItem CreateOutputItemFor(string srcFile, string objFile)
244244
}
245245
}
246246

247-
private bool ShouldCompile(string srcFile, string objFile, string[] depFiles, out string reason)
247+
private static bool ShouldCompile(string srcFile, string objFile, string[] depFiles, out string reason)
248248
{
249249
if (!File.Exists(srcFile))
250250
throw new LogAsErrorException($"Could not find source file {srcFile}");
@@ -271,8 +271,7 @@ bool IsNewerThanOutput(string inFile, string outFile, out string reason)
271271
{
272272
if (!File.Exists(inFile))
273273
{
274-
reason = $"Could not find dependency file {inFile} needed for compiling {srcFile} to {outFile}";
275-
Log.LogWarning(reason);
274+
reason = $"the dependency file {inFile} needed for compiling {srcFile} to {outFile} could not be found.";
276275
return true;
277276
}
278277

src/tasks/WasmAppBuilder/IcallTableGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private void ProcessType(Type type)
206206
}
207207
catch (NotImplementedException nie)
208208
{
209-
Log.LogWarning($"Failed to generate icall function for method '[{method.DeclaringType!.Assembly.GetName().Name}] {className}::{method.Name}'" +
209+
Log.LogWarning(null, "WASM0001", "", "", 0, 0, 0, 0, $"Failed to generate icall function for method '[{method.DeclaringType!.Assembly.GetName().Name}] {className}::{method.Name}'" +
210210
$" because type '{nie.Message}' is not supported for parameter named '{par.Name}'. Ignoring.");
211211
return null;
212212
}

src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private void EmitPInvokeTable(StreamWriter w, Dictionary<string, string> modules
214214
string imports = string.Join(Environment.NewLine,
215215
candidates.Select(
216216
p => $" {p.Method} (in [{p.Method.DeclaringType?.Assembly.GetName().Name}] {p.Method.DeclaringType})"));
217-
Log.LogWarning($"Found a native function ({first.EntryPoint}) with varargs in {first.Module}." +
217+
Log.LogWarning(null, "WASM0001", "", "", 0, 0, 0, 0, $"Found a native function ({first.EntryPoint}) with varargs in {first.Module}." +
218218
" Calling such functions is not supported, and will fail at runtime." +
219219
$" Managed DllImports: {Environment.NewLine}{imports}");
220220

src/tasks/WasmAppBuilder/WasmAppBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private bool ExecuteInternal ()
253253
string fullPath = assembly.GetMetadata("Identity");
254254
if (string.IsNullOrEmpty(culture))
255255
{
256-
Log.LogWarning($"Missing CultureName metadata for satellite assembly {fullPath}");
256+
Log.LogWarning(null, "WASM0002", "", "", 0, 0, 0, 0, $"Missing CultureName metadata for satellite assembly {fullPath}");
257257
continue;
258258
}
259259
// FIXME: validate the culture?
@@ -290,7 +290,7 @@ private bool ExecuteInternal ()
290290

291291
if (firstPath == secondPath)
292292
{
293-
Log.LogWarning($"Found identical vfs mappings for target path: {targetPath}, source file: {firstPath}. Ignoring.");
293+
Log.LogWarning(null, "WASM0003", "", "", 0, 0, 0, 0, $"Found identical vfs mappings for target path: {targetPath}, source file: {firstPath}. Ignoring.");
294294
continue;
295295
}
296296

src/tasks/WasmAppBuilder/WasmLoadAssembliesAndReferences.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private bool AddAssemblyAndReferences(MetadataLoadContext mlc, Assembly assembly
7676
{
7777
if (SkipMissingAssemblies)
7878
{
79-
Log.LogWarning($"Loading assembly reference '{aname}' for '{assembly.GetName()}' failed: {ex.Message} Skipping.");
79+
Log.LogWarning(null, "WASM0004", "", "", 0, 0, 0, 0, $"Loading assembly reference '{aname}' for '{assembly.GetName()}' failed: {ex.Message} Skipping.");
8080
}
8181
else
8282
{

0 commit comments

Comments
 (0)