Skip to content

Remove non-CLS exceptions handlers and CS1058 suppressions (+ cleanup) #10876

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,18 @@ public override bool Execute()
CLRSatelliteEmbeddedResource = clrSatelliteEmbeddedResourceList.ToArray();
}
}
catch (Exception e)
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
if (e is NullReferenceException || e is SEHException)
string errorId = Log.ExtractMessageCode(e.Message, out string message);

if (string.IsNullOrEmpty(errorId))
{
throw;
errorId = UnknownErrorID;
message = SR.Format(SR.UnknownBuildError, message);
}
else
{
string message;
string errorId;

errorId = Log.ExtractMessageCode(e.Message, out message);

if (String.IsNullOrEmpty(errorId))
{
errorId = UnknownErrorID;
message = SR.Format(SR.UnknownBuildError, message);
}
Log.LogError(null, errorId, null, null, 0, 0, 0, 0, message, null);

Log.LogError(null, errorId, null, null, 0, 0, 0, 0, message, null);
}

return false;
}
catch // Non-CLS compliant errors
{
Log.LogErrorWithCodeFromResources(nameof(SR.NonClsError));
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ public override bool Execute()

_nErrors++;
}
catch // Non-CLS compliant errors
{
Log.LogErrorWithCodeFromResources(nameof(SR.NonClsError));
_nErrors++;
}

if (_nErrors > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ public override bool Execute()
_nErrors++;

}
catch // Non-CLS compliant errors
{
Log.LogErrorWithCodeFromResources(nameof(SR.NonClsError));

_nErrors++;
}

if (_nErrors > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,9 @@ public override bool Execute()
Log.LogMessageFromResources(nameof(SR.CommentFileGenerated), _outputFile);
}
}
catch (Exception e)
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
if (e is NullReferenceException || e is SEHException)
{
throw;
}
else
{
Log.LogErrorFromException(e);
return false;
}
}
catch // Non-CLS compliant errors
{
Log.LogErrorWithCodeFromResources(nameof(SR.NonClsError));
Log.LogErrorFromException(e);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,30 +194,17 @@ public override bool Execute()

Log.LogMessageFromResources(MessageImportance.Low, nameof(SR.ResourcesGenerated), resourcesFile);
}
catch (Exception e)
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
if (e is NullReferenceException || e is SEHException)
string errorId = Log.ExtractMessageCode(e.Message, out string message);

if (string.IsNullOrEmpty(errorId))
{
throw;
errorId = UnknownErrorID;
message = SR.Format(SR.UnknownBuildError, message);
}
else
{
string message;
string errorId = Log.ExtractMessageCode(e.Message, out message);

if (string.IsNullOrEmpty(errorId))
{
errorId = UnknownErrorID;
message = SR.Format(SR.UnknownBuildError, message);
}

Log.LogError(null, errorId, null, null, 0, 0, 0, 0, message, null);
return false;
}
}
catch // Non-cls compliant errors
{
Log.LogErrorWithCodeFromResources(nameof(SR.NonClsError));
Log.LogError(null, errorId, null, null, 0, 0, 0, 0, message, null);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,18 @@ public override bool Execute()
{
allFilesOk = ManageUids();
}
catch (Exception e)
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
if (e is NullReferenceException || e is SEHException)
string errorId = Log.ExtractMessageCode(e.Message, out string message);

if (string.IsNullOrEmpty(errorId))
{
throw;
errorId = UnknownErrorID;
message = SR.Format(SR.UnknownBuildError, message);
}
else
{
string message;
string errorId;

errorId = Log.ExtractMessageCode(e.Message, out message);
Log.LogError(null, errorId, null, null, 0, 0, 0, 0, message, null);

if (String.IsNullOrEmpty(errorId))
{
errorId = UnknownErrorID;
message = SR.Format(SR.UnknownBuildError, message);
}

Log.LogError(null, errorId, null, null, 0, 0, 0, 0, message, null);

allFilesOk = false;
}
}
catch // Non-CLS compliant errors
{
Log.LogErrorWithCodeFromResources(nameof(SR.NonClsError));
allFilesOk = false;
}

Expand Down Expand Up @@ -388,28 +373,14 @@ private bool SetupBackupDirectory()

return true;
}
catch (Exception e)
{
if (e is NullReferenceException || e is SEHException)
{
throw;
}
else
{
Log.LogErrorWithCodeFromResources(nameof(SR.IntermediateDirectoryError), _backupPath);
return false;
}
}
catch // Non-cls compliant errors
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
Log.LogErrorWithCodeFromResources(nameof(SR.IntermediateDirectoryError), _backupPath);

return false;
}
}




/// <summary>
/// Verify the Uids in the file
/// </summary>
Expand Down Expand Up @@ -985,16 +956,7 @@ internal bool UpdateUidWrite()
WriteTillEof();
return true;
}
catch (Exception e)
{
if (e is NullReferenceException || e is SEHException)
{
throw;
}

return false;
}
catch
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
return false;
}
Expand Down Expand Up @@ -1024,16 +986,7 @@ internal bool RemoveUidWrite()
WriteTillEof();
return true;
}
catch (Exception e)
{
if (e is NullReferenceException || e is SEHException)
{
throw;
}

return false;
}
catch
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,9 @@ public override bool Execute()
}

}
catch (Exception e)
catch (Exception e) when (e is not (NullReferenceException or SEHException))
{
if (e is NullReferenceException || e is SEHException)
{
throw;
}
else
{
Log.LogErrorFromException(e);
successful = false;
}
}
catch // Non-cls compliant errors
{
Log.LogErrorWithCodeFromResources(nameof(SR.NonClsError));
Log.LogErrorFromException(e);
successful = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
-->
<AssemblyVersion />

<!--
Suppressed Compiler Warnings:

CS1058: A previous catch clause already catches all exceptions. All exceptions
thrown will be wrapped in a System.Runtime.CompilerServices.RuntimeWrappedException
-->
<NoWarn>$(NoWarn);1058</NoWarn>
<NoWarn>$(NoWarn)</NoWarn>

<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<AssemblyName>PresentationBuildTasks</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@
<data name="UnknownBuildError" xml:space="preserve">
<value>Unknown build error, '{0}' </value>
</data>
<data name="NonClsError" xml:space="preserve">
<value>BG1001: Unknown CLS exception.</value>
</data>
<data name="FileNotFound" xml:space="preserve">
<value>BG1002: File '{0}' cannot be found.</value>
</data>
Expand Down Expand Up @@ -834,4 +831,4 @@
<data name="ParserMarkupExtensionMalformedBracketCharacers" xml:space="preserve">
<value>MC8002: BracketCharacter '{0}' at Line Number '{1}' and Line Position '{2}' does not have a corresponding opening/closing BracketCharacter.</value>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,6 @@ private void ResponseCallback(IAsyncResult ar)

throw;
}
catch // catch (and re-throw) all kinds of exceptions so we can inform the other thread
{
// inform other thread of error condition
_erroredOut= true;
_erroredOutException = null;

throw;
}
finally
{
webResponse?.Close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<DefineConstants>$(DefineConstants);CORE_NATIVEMETHODS;PRESENTATION_CORE;COMMONDPS</DefineConstants>
<NoWarn>$(NoWarn);0618;0436;1058;1705;3001;3002;3003;3009;3024</NoWarn>
<NoWarn>$(NoWarn);0618;0436;1705;3001;3002;3003;3009;3024</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- SYSLIB5005: System.Formats.Nrbf is experimental -->
<NoWarn>$(NoWarn);SYSLIB5005</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1747,9 +1747,6 @@
<data name="NextPageText" xml:space="preserve">
<value>Next Page</value>
</data>
<data name="NonCLSException" xml:space="preserve">
<value>Text formatting engine encountered a non-CLS exception.</value>
</data>
<data name="NonPackAppAbsoluteUriNotAllowed" xml:space="preserve">
<value>Unsupported Uri syntax. Method expects a relative Uri or a pack://application:,,,/ form of absolute Uri.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,11 +2402,6 @@
<target state="translated">Další stránka</target>
<note />
</trans-unit>
<trans-unit id="NonCLSException">
<source>Text formatting engine encountered a non-CLS exception.</source>
<target state="translated">Nástroj formátování textu narazil na výjimku, která není CLS.</target>
<note />
</trans-unit>
<trans-unit id="NonPackAppAbsoluteUriNotAllowed">
<source>Unsupported Uri syntax. Method expects a relative Uri or a pack://application:,,,/ form of absolute Uri.</source>
<target state="translated">Nepodporovaná metoda syntaxe identifikátoru URI. Metoda očekává relativní identifikátor URI nebo balík://application:,,,/ jako formu absolutního identifikátoru URI.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,11 +2402,6 @@
<target state="translated">Nächste Seite</target>
<note />
</trans-unit>
<trans-unit id="NonCLSException">
<source>Text formatting engine encountered a non-CLS exception.</source>
<target state="translated">Vom Textformatierungsmodul wurde eine Nicht-CLS-Ausnahme entdeckt.</target>
<note />
</trans-unit>
<trans-unit id="NonPackAppAbsoluteUriNotAllowed">
<source>Unsupported Uri syntax. Method expects a relative Uri or a pack://application:,,,/ form of absolute Uri.</source>
<target state="translated">Nicht unterstützte URI-Syntax. Von der Methode wird ein relativer URI oder die folgende Form eines absoluten URI erwartet: "pack://application:,,,/".</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,11 +2402,6 @@
<target state="translated">Página siguiente</target>
<note />
</trans-unit>
<trans-unit id="NonCLSException">
<source>Text formatting engine encountered a non-CLS exception.</source>
<target state="translated">El motor de formato de texto encontró una excepción no CLS.</target>
<note />
</trans-unit>
<trans-unit id="NonPackAppAbsoluteUriNotAllowed">
<source>Unsupported Uri syntax. Method expects a relative Uri or a pack://application:,,,/ form of absolute Uri.</source>
<target state="translated">Sintaxis de Uri no admitida. El método espera un Uri relativo o un formato pack://aplicación:,,,/ de un Uri absoluto.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,11 +2402,6 @@
<target state="translated">Page suivante</target>
<note />
</trans-unit>
<trans-unit id="NonCLSException">
<source>Text formatting engine encountered a non-CLS exception.</source>
<target state="translated">Le moteur de mise en forme du texte a rencontré une exception autre qu'une exception CLS.</target>
<note />
</trans-unit>
<trans-unit id="NonPackAppAbsoluteUriNotAllowed">
<source>Unsupported Uri syntax. Method expects a relative Uri or a pack://application:,,,/ form of absolute Uri.</source>
<target state="translated">Syntaxe d'URI non prise en charge. La méthode attend un URI relatif ou un pack://application:,,,/ sous la forme d'un URI absolu.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,11 +2402,6 @@
<target state="translated">Pagina successiva</target>
<note />
</trans-unit>
<trans-unit id="NonCLSException">
<source>Text formatting engine encountered a non-CLS exception.</source>
<target state="translated">Motore di formattazione del testo: rilevata eccezione non CLS.</target>
<note />
</trans-unit>
<trans-unit id="NonPackAppAbsoluteUriNotAllowed">
<source>Unsupported Uri syntax. Method expects a relative Uri or a pack://application:,,,/ form of absolute Uri.</source>
<target state="translated">Sintassi URI non supportata. Per il metodo è previsto un URI relativo oppure un URI assoluto di tipo pack://applicazione:,,,/.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2402,11 +2402,6 @@
<target state="translated">次のページ</target>
<note />
</trans-unit>
<trans-unit id="NonCLSException">
<source>Text formatting engine encountered a non-CLS exception.</source>
<target state="translated">テキスト形式設定エンジンに、非 CLS 例外が発生しました。</target>
<note />
</trans-unit>
<trans-unit id="NonPackAppAbsoluteUriNotAllowed">
<source>Unsupported Uri syntax. Method expects a relative Uri or a pack://application:,,,/ form of absolute Uri.</source>
<target state="translated">サポートされていない URI 構文です。メソッドでは、相対 URI または絶対 URI の pack://application:,,,/ 形式が必要です。</target>
Expand Down
Loading
Loading