Skip to content

Commit ec2d44d

Browse files
authored
Improve messaging for Platform Compat Analyzer (#4438)
1 parent 815cf0c commit ec2d44d

17 files changed

+1844
-700
lines changed

src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs

Lines changed: 374 additions & 56 deletions
Large diffs are not rendered by default.

src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/MicrosoftNetCoreAnalyzersResources.resx

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,17 +1434,19 @@
14341434
<data name="UseAsSpanInsteadOfRangeIndexerOnAnArrayCodeFixTitle" xml:space="preserve">
14351435
<value>Use `{0}` instead of Range-based indexers on an array</value>
14361436
</data>
1437-
<data name="PlatformCompatibilityCheckTitle" xml:space="preserve">
1437+
<data name="PlatformCompatibilityTitle" xml:space="preserve">
14381438
<value>Validate platform compatibility</value>
14391439
</data>
1440-
<data name="PlatformCompatibilityCheckDescription" xml:space="preserve">
1440+
<data name="PlatformCompatibilityDescription" xml:space="preserve">
14411441
<value>Using platform dependent API on a component makes the code no longer work across all platforms.</value>
14421442
</data>
1443-
<data name="PlatformCompatibilityCheckSupportedOsVersionMessage" xml:space="preserve">
1444-
<value>'{0}' is supported on '{1}' {2} and later</value>
1443+
<data name="PlatformCompatibilityOnlySupportedCsUnreachableMessage" xml:space="preserve">
1444+
<value>This call site is unreachable on: {2}. '{0}' is only supported on: {1}.</value>
1445+
<comment>This call site is unreachable on: 'browser'. 'SupportedOnWindowsAndBrowser()' is only supported on: 'browser', 'windows'.</comment>
14451446
</data>
1446-
<data name="PlatformCompatibilityCheckUnsupportedOsVersionMessage" xml:space="preserve">
1447-
<value>'{0}' is unsupported on '{1}' {2} and later</value>
1447+
<data name="PlatformCompatibilityUnsupportedCsAllPlatformMessage" xml:space="preserve">
1448+
<value>This call site is reachable on all platforms. '{0}' is unsupported on: {1}.</value>
1449+
<comment>This call site is reachable on all platforms. 'UnsupportedOnWindows()' is unsupported on: 'windows'</comment>
14481450
</data>
14491451
<data name="DoNotUseOutAttributeStringPInvokeParametersDescription" xml:space="preserve">
14501452
<value>String parameters passed by value with the 'OutAttribute' can destabilize the runtime if the string is an interned string.</value>
@@ -1473,13 +1475,47 @@
14731475
<data name="AvoidAssemblyGetFilesInSingleFileMessage" xml:space="preserve">
14741476
<value>'{0}' will throw for assemblies embedded in a single-file app</value>
14751477
</data>
1476-
<data name="PlatformCompatibilityCheckUnsupportedOsMessage" xml:space="preserve">
1477-
<value>'{0}' is unsupported on '{1}'</value>
1478+
<data name="PlatformCompatibilityOnlySupportedCsReachableMessage" xml:space="preserve">
1479+
<value>This call site is reachable on: {2}. '{0}' is only supported on: {1}.</value>
1480+
<comment>This call site is reachable on: 'windows' all versions.'SupportedOnWindowsUnsupportedFromWindows2004()' is only supported on: 'windows' 10.0.2004 and before</comment>
14781481
</data>
1479-
<data name="PlatformCompatibilityCheckSupportedOsMessage" xml:space="preserve">
1480-
<value>'{0}' is supported on '{1}'</value>
1482+
<data name="PlatformCompatibilityOnlySupportedCsAllPlatformMessage" xml:space="preserve">
1483+
<value>This call site is reachable on all platforms. '{0}' is only supported on: {1}.</value>
1484+
<comment>This call site is reachable on all platforms. 'SupportedOnWindowsAndBrowser()' is only supported on: 'windows', 'browser' .</comment>
14811485
</data>
14821486
<data name="PreferStringContainsOverIndexOfCodeFixTitle" xml:space="preserve">
14831487
<value>Replace with 'string.Contains'</value>
14841488
</data>
1489+
<data name="CommaSeparator" xml:space="preserve">
1490+
<value>, </value>
1491+
<comment>Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’}</comment>
1492+
</data>
1493+
<data name="PlatformCompatibilityFromVersionToVersion" xml:space="preserve">
1494+
<value>'{0}' from version {1} to {2}</value>
1495+
<comment>'SupportedOnWindows1903UnsupportedOn2004()' is supported on: 'windows' from version 10.0.1903 to 10.0.2004.</comment>
1496+
</data>
1497+
<data name="PlatformCompatibilitySupportedCsAllPlatformMessage" xml:space="preserve">
1498+
<value>This call site is reachable on all platforms. '{0}' is supported on: {1}.</value>
1499+
<comment>This call site is reachable on all platforms. 'SupportedOnWindows1903UnsupportedFrom2004()' is supported on: 'windows' from version 10.0.1903 to 10.0.2004.</comment>
1500+
</data>
1501+
<data name="PlatformCompatibilitySupportedCsReachableMessage" xml:space="preserve">
1502+
<value>This call site is reachable on: {2}. '{0}' is supported on: {1}.</value>
1503+
<comment>This call site is reachable on: 'windows' 10.0.2000 and before. 'UnsupportedOnWindowsSupportedOn1903()' is supported on: 'windows' 10.0.1903 and later.</comment>
1504+
</data>
1505+
<data name="PlatformCompatibilityUnsupportedCsReachableMessage" xml:space="preserve">
1506+
<value>This call site is reachable on: {2}. '{0}' is unsupported on: {1}.</value>
1507+
<comment>This call site is reachable on: 'windows', 'browser'. 'UnsupportedOnBrowser()' is unsupported on: 'browser'.</comment>
1508+
</data>
1509+
<data name="PlatformCompatibilityVersionAndBefore" xml:space="preserve">
1510+
<value>'{0}' {1} and before</value>
1511+
<comment>'SupportedOnWindowsUnsupportedFromWindows2004()' is only supported on: 'windows' 10.0.2004 and before.</comment>
1512+
</data>
1513+
<data name="PlatformCompatibilityVersionAndLater" xml:space="preserve">
1514+
<value>'{0}' {1} and later</value>
1515+
<comment>'SupportedOnWindows10()' is only supported on: 'windows' 10.0 and later.</comment>
1516+
</data>
1517+
<data name="PlatformCompatibilityAllVersions" xml:space="preserve">
1518+
<value>'{0}' all versions</value>
1519+
<comment>This call site is reachable on: 'Windows' all versions.</comment>
1520+
</data>
14851521
</root>

src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/xlf/MicrosoftNetCoreAnalyzersResources.cs.xlf

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@
172172
<target state="translated">Spolehlivost</target>
173173
<note />
174174
</trans-unit>
175+
<trans-unit id="CommaSeparator">
176+
<source>, </source>
177+
<target state="new">, </target>
178+
<note>Separator used for separating list of platform names: {API} is only supported on: {‘windows’, ‘browser’, ‘linux’}</note>
179+
</trans-unit>
175180
<trans-unit id="DataSetDataTableInDeserializableObjectGraphMessage">
176181
<source>When deserializing untrusted input, deserializing a {0} object is insecure. '{1}' either is or derives from {0}</source>
177182
<target state="translated">Při deserializaci nedůvěryhodného vstupu není deserializace objektu {0} bezpečná. Objekt {1} je buď objektem {0}, nebo je z tohoto objektu odvozený.</target>
@@ -1512,35 +1517,70 @@
15121517
<target state="translated">Metody P/Invoke nemají být viditelné</target>
15131518
<note />
15141519
</trans-unit>
1515-
<trans-unit id="PlatformCompatibilityCheckDescription">
1520+
<trans-unit id="PlatformCompatibilityAllVersions">
1521+
<source>'{0}' all versions</source>
1522+
<target state="new">'{0}' all versions</target>
1523+
<note>This call site is reachable on: 'Windows' all versions.</note>
1524+
</trans-unit>
1525+
<trans-unit id="PlatformCompatibilityDescription">
15161526
<source>Using platform dependent API on a component makes the code no longer work across all platforms.</source>
1517-
<target state="translated">Když se pro komponentu použije závislé rozhraní API, kód už nebude fungovat na všech platformách.</target>
1527+
<target state="new">Using platform dependent API on a component makes the code no longer work across all platforms.</target>
15181528
<note />
15191529
</trans-unit>
1520-
<trans-unit id="PlatformCompatibilityCheckSupportedOsMessage">
1521-
<source>'{0}' is supported on '{1}'</source>
1522-
<target state="translated">{0} se podporuje v {1}.</target>
1523-
<note />
1530+
<trans-unit id="PlatformCompatibilityFromVersionToVersion">
1531+
<source>'{0}' from version {1} to {2}</source>
1532+
<target state="new">'{0}' from version {1} to {2}</target>
1533+
<note>'SupportedOnWindows1903UnsupportedOn2004()' is supported on: 'windows' from version 10.0.1903 to 10.0.2004.</note>
15241534
</trans-unit>
1525-
<trans-unit id="PlatformCompatibilityCheckSupportedOsVersionMessage">
1526-
<source>'{0}' is supported on '{1}' {2} and later</source>
1527-
<target state="translated">{0} se podporuje v {1} {2} a novějších.</target>
1528-
<note />
1535+
<trans-unit id="PlatformCompatibilityOnlySupportedCsAllPlatformMessage">
1536+
<source>This call site is reachable on all platforms. '{0}' is only supported on: {1}.</source>
1537+
<target state="new">This call site is reachable on all platforms. '{0}' is only supported on: {1}.</target>
1538+
<note>This call site is reachable on all platforms. 'SupportedOnWindowsAndBrowser()' is only supported on: 'windows', 'browser' .</note>
1539+
</trans-unit>
1540+
<trans-unit id="PlatformCompatibilityOnlySupportedCsReachableMessage">
1541+
<source>This call site is reachable on: {2}. '{0}' is only supported on: {1}.</source>
1542+
<target state="new">This call site is reachable on: {2}. '{0}' is only supported on: {1}.</target>
1543+
<note>This call site is reachable on: 'windows' all versions.'SupportedOnWindowsUnsupportedFromWindows2004()' is only supported on: 'windows' 10.0.2004 and before</note>
1544+
</trans-unit>
1545+
<trans-unit id="PlatformCompatibilityOnlySupportedCsUnreachableMessage">
1546+
<source>This call site is unreachable on: {2}. '{0}' is only supported on: {1}.</source>
1547+
<target state="new">This call site is unreachable on: {2}. '{0}' is only supported on: {1}.</target>
1548+
<note>This call site is unreachable on: 'browser'. 'SupportedOnWindowsAndBrowser()' is only supported on: 'browser', 'windows'.</note>
15291549
</trans-unit>
1530-
<trans-unit id="PlatformCompatibilityCheckTitle">
1550+
<trans-unit id="PlatformCompatibilitySupportedCsAllPlatformMessage">
1551+
<source>This call site is reachable on all platforms. '{0}' is supported on: {1}.</source>
1552+
<target state="new">This call site is reachable on all platforms. '{0}' is supported on: {1}.</target>
1553+
<note>This call site is reachable on all platforms. 'SupportedOnWindows1903UnsupportedFrom2004()' is supported on: 'windows' from version 10.0.1903 to 10.0.2004.</note>
1554+
</trans-unit>
1555+
<trans-unit id="PlatformCompatibilitySupportedCsReachableMessage">
1556+
<source>This call site is reachable on: {2}. '{0}' is supported on: {1}.</source>
1557+
<target state="new">This call site is reachable on: {2}. '{0}' is supported on: {1}.</target>
1558+
<note>This call site is reachable on: 'windows' 10.0.2000 and before. 'UnsupportedOnWindowsSupportedOn1903()' is supported on: 'windows' 10.0.1903 and later.</note>
1559+
</trans-unit>
1560+
<trans-unit id="PlatformCompatibilityTitle">
15311561
<source>Validate platform compatibility</source>
1532-
<target state="translated">Ověřit kompatibilitu platformy</target>
1562+
<target state="new">Validate platform compatibility</target>
15331563
<note />
15341564
</trans-unit>
1535-
<trans-unit id="PlatformCompatibilityCheckUnsupportedOsMessage">
1536-
<source>'{0}' is unsupported on '{1}'</source>
1537-
<target state="translated">{0} se v {1} nepodporuje.</target>
1538-
<note />
1565+
<trans-unit id="PlatformCompatibilityUnsupportedCsAllPlatformMessage">
1566+
<source>This call site is reachable on all platforms. '{0}' is unsupported on: {1}.</source>
1567+
<target state="new">This call site is reachable on all platforms. '{0}' is unsupported on: {1}.</target>
1568+
<note>This call site is reachable on all platforms. 'UnsupportedOnWindows()' is unsupported on: 'windows'</note>
15391569
</trans-unit>
1540-
<trans-unit id="PlatformCompatibilityCheckUnsupportedOsVersionMessage">
1541-
<source>'{0}' is unsupported on '{1}' {2} and later</source>
1542-
<target state="translated">{0} se v {1} {2} a novějších nepodporuje.</target>
1543-
<note />
1570+
<trans-unit id="PlatformCompatibilityUnsupportedCsReachableMessage">
1571+
<source>This call site is reachable on: {2}. '{0}' is unsupported on: {1}.</source>
1572+
<target state="new">This call site is reachable on: {2}. '{0}' is unsupported on: {1}.</target>
1573+
<note>This call site is reachable on: 'windows', 'browser'. 'UnsupportedOnBrowser()' is unsupported on: 'browser'.</note>
1574+
</trans-unit>
1575+
<trans-unit id="PlatformCompatibilityVersionAndBefore">
1576+
<source>'{0}' {1} and before</source>
1577+
<target state="new">'{0}' {1} and before</target>
1578+
<note>'SupportedOnWindowsUnsupportedFromWindows2004()' is only supported on: 'windows' 10.0.2004 and before.</note>
1579+
</trans-unit>
1580+
<trans-unit id="PlatformCompatibilityVersionAndLater">
1581+
<source>'{0}' {1} and later</source>
1582+
<target state="new">'{0}' {1} and later</target>
1583+
<note>'SupportedOnWindows10()' is only supported on: 'windows' 10.0 and later.</note>
15441584
</trans-unit>
15451585
<trans-unit id="PotentialReferenceCycleInDeserializedObjectGraphDescription">
15461586
<source>Review code that processes untrusted deserialized data for handling of unexpected reference cycles. An unexpected reference cycle should not cause the code to enter an infinite loop. Otherwise, an unexpected reference cycle can allow an attacker to DOS or exhaust the memory of the process when deserializing untrusted data.</source>

0 commit comments

Comments
 (0)