Skip to content

Remove Verify classes, use standard BCL throw helpers instead #10882

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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 @@ -359,7 +359,7 @@ public void Dispose()
///</remarks>
public void AddHook(HwndSourceHook hook)
{
Verify.IsNotNull(hook, "hook");
ArgumentNullException.ThrowIfNull(hook, nameof(hook));

CheckDisposed(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,6 @@
<Compile Include="System\Windows\Standard\NativeMethods.cs" />
<Compile Include="System\Windows\Standard\ShellProvider.cs" />
<Compile Include="System\Windows\Standard\Utilities.cs" />
<Compile Include="System\Windows\Standard\Verify.cs" />
<Compile Include="System\Windows\StartupEventArgs.cs" />
<Compile Include="System\Windows\StaticResourceExtension.cs" />
<Compile Include="System\Windows\Style.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3834,6 +3834,12 @@ Do you want to replace it?</value>
<data name="ValueSerializerContextUnavailable" xml:space="preserve">
<value>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</value>
</data>
<data name="Verify_ApartmentState" xml:space="preserve">
<value>This operation requires the thread's apartment state to be '{0}'.</value>
</data>
<data name="Verify_FileExists" xml:space="preserve">
<value>No file exists at '{0}'.</value>
</data>
<data name="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges" xml:space="preserve">
<value>This collection does not support changing values with specific indexes.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Chcete ho nahradit?</target>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">Konverze prováděná funkcí ValueSerializer se nezdařila, protože nebyl dodán kontext IValueSerializerContext {0}.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Tato operace vyžaduje, aby stav vlákna modelu apartment byl {0}.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">V {0} neexistuje žádný soubor.</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Möchten Sie das Element ersetzen?</target>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">Fehler beim Konvertieren durch "ValueSerializer", da "{0}" nicht für "IValueSerializerContext" bereitgestellt wurde.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Für diesen Vorgang muss der Apartmentzustand des Threads "{0}" sein.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">Unter "{0}" sind keine Dateien vorhanden.</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Do you want to replace it?</source>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">Error de conversión mediante ValueSerializer porque IValueSerializerContext no se proporcionó '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Esta operación requiere que el estado del apartamento del subproceso sea "{0}".</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">No hay ningún archivo en "{0}".</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Voulez-vous le remplacer ?</target>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">Échec de la conversion par un ValueSerializer parce que le IValueSerializerContext n'était pas fourni '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Pour cette opération, l'état de cloisonnement du thread doit être '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">Aucun fichier n'existe à l'emplacement '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6267,6 +6267,16 @@ Sostituirlo?</target>
<source>'{0}' is not a valid value for this property. Valid values are from Int32.MinValue through Int32.MaxValue.</source>
<target state="translated">'{0}' non è un valore valido per questa proprietà. I valori validi sono compresi nell'intervallo da Int32.MinValue a Int32.MaxValue.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Questa operazione richiede che lo stato dell'apartment del thread sia '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">Non esiste alcun file in '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="ValueSerializerContextUnavailable">
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Do you want to replace it?</source>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">IValueSerializerContext に '{0}' が提供されないため、ValueSerializer による変換に失敗しました。</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">この操作を実行するには、スレッドのアパートメント状態が '{0}' である必要があります。</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">'{0}' にファイルがありません。</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Do you want to replace it?</source>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">IValueSerializerContext에 '{0}'이(가) 제공되지 않아 ValueSerializer에서 변환에 실패했습니다.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">이 작업을 수행하려면 스레드의 아파트가 '{0}' 상태여야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">'{0}'에 파일이 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Czy chcesz go zastąpić?</target>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">Konwersja według ValueSerializer nie powiodła się, ponieważ nie dostarczono IValueSerializerContext „{0}”.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Ta operacja wymaga stanu apartamentu wątku „{0}”.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">Żaden plik nie istnieje w „{0}”.</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Deseja substituí-lo?</target>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">Falha na conversão executada por ValueSerializer porque IValueSerializerContext não foi fornecido '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Esta operação exige que o estado do apartment do thread seja '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">Não existe arquivo em '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Do you want to replace it?</source>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">Преобразование с помощью ValueSerializer не удалось, так как для IValueSerializerContext не было задано значение "{0}".</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Эта операция требует, чтобы подразделение потока находилось в состоянии "{0}".</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">Файл не существует в "{0}".</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Değiştirmek istiyor musunuz?</target>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">IValueSerializerContext için '{0}' sağlanmadığından, ValueSerializer temelinde dönüştürme yapılamadı.</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">Bu işlem iş parçacığı grup durumunun '{0}' olmasını gerektirir.</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">'{0}' konumunda dosya yok.</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6277,6 +6277,16 @@ Do you want to replace it?</source>
<source>This collection does not support changing values with specific indexes.</source>
<target state="translated">此集合不支持更改具有特定索引的值。</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">此操作要求线程的单元状态为“{0}”。</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">“{0}”处没有文件。</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_IsReadOnly">
<source>The collection cannot be modified.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,16 @@ Do you want to replace it?</source>
<source>Conversion by a ValueSerializer failed because the IValueSerializerContext was not provided '{0}'.</source>
<target state="translated">ValueSerializer 執行轉換失敗,因為 IValueSerializerContext 未提供 '{0}'。</target>
<note />
</trans-unit>
<trans-unit id="Verify_ApartmentState">
<source>This operation requires the thread's apartment state to be '{0}'.</source>
<target state="translated">此作業需要執行緒的 Apartment 狀態為 '{0}'。</target>
<note />
</trans-unit>
<trans-unit id="Verify_FileExists">
<source>No file exists at '{0}'.</source>
<target state="translated">'{0}' 沒有任何檔案。</target>
<note />
</trans-unit>
<trans-unit id="VirtualizedCellInfoCollection_DoesNotSupportIndexChanges">
<source>This collection does not support changing values with specific indexes.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ static JumpList()
/// </remarks>
public static void AddToRecentCategory(string itemPath)
{
Verify.FileExists(itemPath, "itemPath");
ArgumentException.ThrowIfNullOrEmpty(itemPath, nameof(itemPath));

if (!File.Exists(itemPath))
{
throw new ArgumentException(SR.Format(SR.Verify_FileExists, itemPath), nameof(itemPath));
}

itemPath = Path.GetFullPath(itemPath);
NativeMethods2.SHAddToRecentDocs(itemPath);
}
Expand All @@ -138,7 +144,8 @@ public static void AddToRecentCategory(string itemPath)
/// </remarks>
public static void AddToRecentCategory(JumpPath jumpPath)
{
Verify.IsNotNull(jumpPath, "jumpPath");
ArgumentNullException.ThrowIfNull(jumpPath, nameof(jumpPath));

AddToRecentCategory(jumpPath.Path);
}

Expand All @@ -150,7 +157,7 @@ public static void AddToRecentCategory(JumpPath jumpPath)
/// </remarks>
public static void AddToRecentCategory(JumpTask jumpTask)
{
Verify.IsNotNull(jumpTask, "jumpTask");
ArgumentNullException.ThrowIfNull(jumpTask, nameof(jumpTask));

// SHAddToRecentDocs only allows IShellLinks in Windows 7 and later.
// Silently fail this if that's not the case.
Expand Down Expand Up @@ -212,7 +219,7 @@ public static void ReleaseShellObjects(List<_ShellObjectPair> list)
/// </summary>
public static void SetJumpList(Application application, JumpList value)
{
Verify.IsNotNull(application, "application");
ArgumentNullException.ThrowIfNull(application, nameof(application));

lock (s_lock)
{
Expand All @@ -238,7 +245,7 @@ public static void SetJumpList(Application application, JumpList value)
/// </summary>
public static JumpList GetJumpList(Application application)
{
Verify.IsNotNull(application, "application");
ArgumentNullException.ThrowIfNull(application, nameof(application));

JumpList value;
s_applicationMap.TryGetValue(application, out value);
Expand Down Expand Up @@ -443,7 +450,11 @@ private void ApplyFromApplication()
private void ApplyList()
{
Debug.Assert(_initializing == false);
Verify.IsApartmentState(ApartmentState.STA);

if (Thread.CurrentThread.GetApartmentState() is not ApartmentState.STA)
{
throw new InvalidOperationException(SR.Format(SR.Verify_ApartmentState, ApartmentState.STA));
}

// We don't want to force applications to conditionally check this before constructing a JumpList,
// but if we're not on 7 then this isn't going to work. Fail fast.
Expand Down
Loading