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

Consider readonly TestContext as valid #4053

Merged
merged 12 commits into from
Nov 19, 2024
11 changes: 7 additions & 4 deletions src/Adapter/MSTest.TestAdapter/Discovery/TypeValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ internal static bool HasCorrectTestContextSignature(Type type)
return true;
}

// NOTE: It's okay to not have a setter for the property at all.
// The user may set the TestContext property in the constructor.
// In case the user didn't set it in the constructor, the TestContextShouldBeValidAnalyzer will report a diagnostic.
Evangelink marked this conversation as resolved.
Show resolved Hide resolved
foreach (PropertyInfo pinfo in propertyInfo)
{
MethodInfo? setInfo = pinfo.SetMethod;
if (setInfo == null)
MethodInfo? getInfo = pinfo.GetMethod;
if (getInfo == null)
{
// we have a getter, but not a setter.
// we don't have a getter.
return false;
}

if (setInfo.IsPrivate || setInfo.IsStatic || setInfo.IsAbstract)
if (getInfo.IsPrivate || getInfo.IsStatic || getInfo.IsAbstract)
{
return false;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Adapter/MSTest.TestAdapter/Resources/Resource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<value>(Failed to get the message for an exception of type {0} due to an exception.)</value>
</data>
<data name="UTA_ErrorInValidTestContextSignature" xml:space="preserve">
<value>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</value>
<value>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</value>
</data>
<data name="UTA_ErrorNonPublicTestClass" xml:space="preserve">
<value>UTA001: TestClass attribute defined on non-public class {0}</value>
Expand Down Expand Up @@ -417,4 +417,4 @@ but received {4} argument(s), with types '{5}'.</value>
<data name="DuplicateConfigurationError" xml:space="preserve">
<value>Both '.runsettings' and '.testconfig.json' files have been detected. Please select only one of these test configuration files.</value>
</data>
</root>
</root>
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ byl však přijat tento počet argumentů: {4} s typy {5}.</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: Třída {0} neobsahuje platnou vlastnost TestContext. Vlastnost TestContext musí být typu TestContext, musí být nestatická, veřejná a nemůže být určena jenom pro čtení. Například: public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: Třída {0} neobsahuje platnou vlastnost TestContext. Vlastnost TestContext musí být typu TestContext, musí být nestatická, veřejná a nemůže být určena jenom pro čtení. Například: public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ aber empfing {4} Argument(e) mit den Typen „{5}“.</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: Die Klasse '{0}' weist keine gültige Eigenschaft 'TestContext' auf. 'TestContext' muss vom Typ 'TestContext', nicht statisch und öffentlich sein und darf nicht schreibgeschützt sein. Beispiel: 'public TestContext TestContext'.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: Die Klasse '{0}' weist keine gültige Eigenschaft 'TestContext' auf. 'TestContext' muss vom Typ 'TestContext', nicht statisch und öffentlich sein und darf nicht schreibgeschützt sein. Beispiel: 'public TestContext TestContext'.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ pero recibió {4} argumento(s), con los tipos "{5}".</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: la clase {0} no tiene la propiedad TestContext válida. TestContext debe ser de tipo TestContext, debe ser no estática, pública y no debe ser de solo lectura. Por ejemplo: public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: la clase {0} no tiene la propiedad TestContext válida. TestContext debe ser de tipo TestContext, debe ser no estática, pública y no debe ser de solo lectura. Por ejemplo: public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ mais a reçu {4} argument(s), avec les types « {5} ».</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031 : la classe {0} ne possède pas une propriété TestContext valide. TestContext doit être de type TestContext, doit être non statique, publique, et ne doit pas être en lecture seule. Par exemple : public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031 : la classe {0} ne possède pas une propriété TestContext valide. TestContext doit être de type TestContext, doit être non statique, publique, et ne doit pas être en lecture seule. Par exemple : public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ ma ha ricevuto {4} argomenti, con tipi "{5}".</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: la classe {0} non contiene una proprietà TestContext valida. TestContext deve essere una proprietà di tipo TestContext, non statica, pubblica e non di sola lettura. Esempio: public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: la classe {0} non contiene una proprietà TestContext valida. TestContext deve essere una proprietà di tipo TestContext, non statica, pubblica e non di sola lettura. Esempio: public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ but received {4} argument(s), with types '{5}'.</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: クラス {0} は有効な TestContext プロパティを含んでいません。TestContext は、型 TestContext でなければなりません。また、non-static および public である必要があり、読み取り専用に指定することはできません。例: public TestContext TestContext。</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: クラス {0} は有効な TestContext プロパティを含んでいません。TestContext は、型 TestContext でなければなりません。また、non-static および public である必要があり、読み取り専用に指定することはできません。例: public TestContext TestContext。</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ but received {4} argument(s), with types '{5}'.</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: {0} 클래스에 올바른 TestContext 속성이 없습니다. TestContext는 TestContext 형식이어야 하고 읽기 전용이 아니어야 하며, static이 아니고 public이어야 합니다. 예: public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: {0} 클래스에 올바른 TestContext 속성이 없습니다. TestContext는 TestContext 형식이어야 하고 읽기 전용이 아니어야 하며, static이 아니고 public이어야 합니다. 예: public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ ale liczba odebranych argumentów to {4} z typami „{5}”.</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: Klasa {0} nie ma prawidłowej właściwości TestContext. Właściwość TestContext musi być typu TestContext, niestatyczna, publiczna i nie może być tylko do odczytu. Na przykład : public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: Klasa {0} nie ma prawidłowej właściwości TestContext. Właściwość TestContext musi być typu TestContext, niestatyczna, publiczna i nie może być tylko do odczytu. Na przykład : public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ mas {4} argumentos recebidos, com tipos '{5}'.</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: classe {0} não tem propriedade TestContext válida. TestContext deve ser de tipo TestContext, deve ser não estático, público e não deve ser somente leitura. Por exemplo: public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: classe {0} não tem propriedade TestContext válida. TestContext deve ser de tipo TestContext, deve ser não estático, público e não deve ser somente leitura. Por exemplo: public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ but received {4} argument(s), with types '{5}'.</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: в классе {0} отсутствует допустимое свойство TestContext. Свойство TestContext должно иметь тип TestContext, быть нестатическим, открытым и не должно быть предназначено только для чтения. Например: public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: в классе {0} отсутствует допустимое свойство TestContext. Свойство TestContext должно иметь тип TestContext, быть нестатическим, открытым и не должно быть предназначено только для чтения. Например: public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ ancak, '{5}' türüyle {4} argüman aldı.</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: {0} sınıfı geçerli bir TestContext özelliğine sahip değil. TestContext, TestContext türünde olmalı, statik olmamalı, genel olmalı ve salt okunur olmamalı. Örnek: public TestContext TestContext.</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: {0} sınıfı geçerli bir TestContext özelliğine sahip değil. TestContext, TestContext türünde olmalı, statik olmamalı, genel olmalı ve salt okunur olmamalı. Örnek: public TestContext TestContext.</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ but received {4} argument(s), with types '{5}'.</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ErrorInValidTestContextSignature">
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, public and must not be read-only. For example: public TestContext TestContext.</source>
<target state="translated">UTA031: 类 {0} 没有有效的 TestContext 属性。TestContext 的类型必须为 TestContext,必须是非静态的、公共的而且不能为只读。例如: public TestContext TestContext。</target>
<note></note>
<source>UTA031: class {0} does not have valid TestContext property. TestContext must be of type TestContext, must be non-static, and must be public. For example: public TestContext TestContext.</source>
<target state="needs-review-translation">UTA031: 类 {0} 没有有效的 TestContext 属性。TestContext 的类型必须为 TestContext,必须是非静态的、公共的而且不能为只读。例如: public TestContext TestContext。</target>
<note />
</trans-unit>
<trans-unit id="UTA_ErrorNonPublicTestClass">
<source>UTA001: TestClass attribute defined on non-public class {0}</source>
Expand Down
Loading