Skip to content

Commit

Permalink
Splittig resources into shared ones and specific ones for given language
Browse files Browse the repository at this point in the history
  • Loading branch information
tpodolak committed Jul 14, 2018
1 parent bc8b299 commit a602c38
Show file tree
Hide file tree
Showing 17 changed files with 783 additions and 899 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
<PackagePath>analyzers/dotnet/cs</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
306 changes: 0 additions & 306 deletions src/NSubstitute.Analyzers.CSharp/Resources.Designer.cs

Large diffs are not rendered by default.

138 changes: 1 addition & 137 deletions src/NSubstitute.Analyzers.CSharp/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,172 +117,36 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="NonVirtualSetupSpecificationDescription" xml:space="preserve">
<value>Non-virtual members can not be intercepted.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="NonVirtualSetupSpecificationMessageFormat" xml:space="preserve">
<value>Member {0} can not be intercepted. Only interface members and virtual, overriding, and abstract members can be intercepted.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="NonVirtualSetupSpecificationTitle" xml:space="preserve">
<value>Non-virtual setup specification.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="UnusedReceivedDescription" xml:space="preserve">
<value>Unused received check.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="UnusedReceivedMessageFormat" xml:space="preserve">
<value>Unused received check. To fix, make sure there is a call after "{0}". Correct: "sub.{0}().SomeCall();". Incorrect: "sub.{0}();"</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="UnusedReceivedTitle" xml:space="preserve">
<value>Received check.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="UnusedReceivedForOrdinaryMethodDescription" xml:space="preserve">
<value>Unused received check.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="UnusedReceivedForOrdinaryMethodMessageFormat" xml:space="preserve">
<value>Unused received check. To fix, make sure there is a call after "{0}". Correct: "SubstituteExtensions.{0}(sub).SomeCall();". Incorrect: "SubstituteExtensions.{0}(sub);"</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="UnusedReceivedForOrdinaryMethodTitle" xml:space="preserve">
<value>Received check.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteForPartsOfUsedForInterfaceDescription" xml:space="preserve">
<value>Can only substitute for parts of classes, not interfaces or delegates.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteForPartsOfUsedForInterfaceMessageFormat" xml:space="preserve">
<value>Can only substitute for parts of classes, not interfaces or delegates. Use Substitute.For&lt;{0}&gt; instead of Substitute.ForPartsOf&lt;{0}&gt; here.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteForPartsOfUsedForInterfaceTitle" xml:space="preserve">
<value>Substitute.ForPartsOf used for interface.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteForWithoutAccessibleConstructorDescription" xml:space="preserve">
<value>Could not find accessible constructor.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteForWithoutAccessibleConstructorMessageFormat" xml:space="preserve">
<value>Could not find accessible constructor. Make sure that type {0} exposes public or protected constructors.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteForWithoutAccessibleConstructorTitle" xml:space="preserve">
<value>Could not find accessible constructor.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteForConstructorParametersMismatchDescription" xml:space="preserve">
<value>Constructor parameters count mismatch.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteForConstructorParametersMismatchMessageFormat" xml:space="preserve">
<value>The number of arguments passed to {0} do not match the number of constructor arguments for {1}. Check the constructors for {1} and make sure you have passed the required number of arguments.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteForConstructorParametersMismatchTitle" xml:space="preserve">
<value>Constructor parameters count mismatch.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteForInternalMemberDescription" xml:space="preserve">
<value>Substitute for internal member.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteForInternalMemberMessageFormat" xml:space="preserve">
<data name="SubstituteForInternalMemberMessageFormat" xml:space="preserve">
<value>Can not substitute for internal type. To substitute for internal type expose your type to DynamicProxyGenAssembly2 via [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteForInternalMemberTitle" xml:space="preserve">
<value>Can not create.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteConstructorMismatchDescription" xml:space="preserve">
<value>Unable to find matching constructor.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteConstructorMismatchMessageFormat" xml:space="preserve">
<value>Arguments passed to {0} do not match the constructor arguments for {1}. Check the constructors for {1} and make sure you have passed the required arguments and argument types.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteConstructorMismatchMemberTitle" xml:space="preserve">
<value>Unable to find matching constructor.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteMultipleClassesDescription" xml:space="preserve">
<value>Can not substitute for multiple classes.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteMultipleClassesMessageFormat" xml:space="preserve">
<value>Can not substitute for multiple classes. To substitute for multiple types only one type can be a concrete class; other types can only be interfaces.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteMultipleClassesMemberTitle" xml:space="preserve">
<value>Can not substitute for multiple classes.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteConstructorArgumentsForInterfaceDescription" xml:space="preserve">
<value>Can not provide constructor arguments when substituting for an interface.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteConstructorArgumentsForInterfaceMessageFormat" xml:space="preserve">
<value>Can not provide constructor arguments when substituting for an interface. Use Substitute.For&lt;{0}&gt;() instead.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteConstructorArgumentsForInterfaceMemberTitle" xml:space="preserve">
<value>Can not provide constructor arguments when substituting for an interface.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="SubstituteConstructorArgumentsForDelegateeDescription" xml:space="preserve">
<value>Can not provide constructor arguments when substituting for a delegate.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="SubstituteConstructorArgumentsForDelegateMessageFormat" xml:space="preserve">
<value>Can not provide constructor arguments when substituting for a delegate. Use Substitute.For&lt;{0}&gt;() instead.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="SubstituteConstructorArgumentsForDelegateMemberTitle" xml:space="preserve">
<value>Can not provide constructor arguments when substituting for a delegate.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="NonVirtualReceivedSetupSpecificationDescription" xml:space="preserve">
<value>Non-virtual members can not be intercepted.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="NonVirtualReceivedSetupSpecificationMessageFormat" xml:space="preserve">
<value>Member {0} can not be intercepted. Only interface members and virtual, overriding, and abstract members can be intercepted.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="NonVirtualReceivedSetupSpecificationTitle" xml:space="preserve">
<value>Non-virtual setup specification.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="NonVirtualWhenSetupSpecificationDescription" xml:space="preserve">
<value>Non-virtual members can not be intercepted.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="NonVirtualWhenSetupSpecificationMessageFormat" xml:space="preserve">
<value>Member {0} can not be intercepted. Only interface members and virtual, overriding, and abstract members can be intercepted.</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="NonVirtualWhenSetupSpecificationTitle" xml:space="preserve">
<value>Non-virtual setup specification.</value>
<comment>The title of the diagnostic.</comment>
</data>
<data name="ReEntrantSubstituteCallDescription" xml:space="preserve">
<value>Re-entrant substitute call.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="ReEntrantSubstituteCallMessageFormat" xml:space="preserve">
<value>{0}() is set with a method that itself calls {1}. This can cause problems with NSubstitute. Consider replacing with a lambda: {0}(x => {2}).</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="ReEntrantSubstituteCallTitle" xml:space="preserve">
<value>Re-entrant substitute call.</value>
<comment>The title of the diagnostic.</comment>
</data>
</root>
7 changes: 5 additions & 2 deletions src/NSubstitute.Analyzers.Shared/DiagnosticDescriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NSubstitute.Analyzers.Shared
{
internal class DiagnosticDescriptors<T>
{
public static readonly ResourceManager ResourceManager =
private static readonly ResourceManager SpecificResourceManager =
new ResourceManager(
$"{typeof(T).GetTypeInfo().Assembly.GetName().Name}.Resources",
typeof(T).GetTypeInfo().Assembly);
Expand Down Expand Up @@ -134,7 +134,10 @@ private static DiagnosticDescriptor CreateDiagnosticDescriptor(

private static LocalizableResourceString GetDiagnosticResourceString(string name, string propertyName)
{
return new LocalizableResourceString(name + propertyName, ResourceManager, typeof(T));
var localizableResource = name + propertyName;
var resourceManager = string.IsNullOrWhiteSpace(SpecificResourceManager.GetString(localizableResource)) ? SharedResourceManager.Instance : SpecificResourceManager;

return new LocalizableResourceString(localizableResource, resourceManager, typeof(T));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

[assembly: InternalsVisibleTo("NSubstitute.Analyzers.CSharp")]
[assembly: InternalsVisibleTo("NSubstitute.Analyzers.Tests.CSharp")]
[assembly: InternalsVisibleTo("NSubstitute.Analyzers.Tests.Shared")]
[assembly: InternalsVisibleTo("NSubstitute.Analyzers.VisualBasic")]
[assembly: InternalsVisibleTo("NSubstitute.Analyzers.Tests.VisualBasic")]
Loading

0 comments on commit a602c38

Please sign in to comment.