Skip to content

Commit

Permalink
Microsoft.Data.Sqlite: Review resources
Browse files Browse the repository at this point in the history
Part of #7201
  • Loading branch information
bricelam committed Sep 10, 2020
1 parent 77c16b4 commit 97a55ec
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ internal static class SQLitePCLExtensions
};

public static bool? EncryptionSupported()
=> _knownLibraries.TryGetValue(raw.GetNativeLibraryName(), out var supported)
=> EncryptionSupported(out _);

public static bool? EncryptionSupported(out string libraryName)
{
libraryName = raw.GetNativeLibraryName();

return _knownLibraries.TryGetValue(libraryName, out var supported)
? supported
: default(bool?);
}
}
}
18 changes: 10 additions & 8 deletions src/Microsoft.Data.Sqlite.Core/Properties/Resources.Designer.cs

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

12 changes: 6 additions & 6 deletions src/Microsoft.Data.Sqlite.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@
<value>Invalid attempt to call {operation} when reader is closed.</value>
</data>
<data name="InvalidCommandType" xml:space="preserve">
<value>The CommandType '{commandType}' is invalid.</value>
<value>The CommandType '{commandType}' is not supported.</value>
</data>
<data name="InvalidIsolationLevel" xml:space="preserve">
<value>The IsolationLevel '{isolationLevel}' is invalid.</value>
<value>The IsolationLevel '{isolationLevel}' is not supported.</value>
</data>
<data name="InvalidParameterDirection" xml:space="preserve">
<value>The ParameterDirection '{direction}' is invalid.</value>
<value>The ParameterDirection '{direction}' is not supported.</value>
</data>
<data name="KeywordNotSupported" xml:space="preserve">
<value>Keyword not supported: '{keyword}'.</value>
<value>Connection string keyword '{keyword}' is not supported. For a possible alternative, see https://go.microsoft.com/fwlink/?linkid=2142181.</value>
</data>
<data name="MissingParameters" xml:space="preserve">
<value>Must add values for the following parameters: {parameters}</value>
Expand All @@ -163,7 +163,7 @@
<value>This SqliteTransaction has completed; it is no longer usable.</value>
</data>
<data name="TransactionConnectionMismatch" xml:space="preserve">
<value>The transaction object is not associated with the connection object.</value>
<value>The transaction object is not associated with the same connection object as this command.</value>
</data>
<data name="TransactionRequired" xml:space="preserve">
<value>Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.</value>
Expand Down Expand Up @@ -217,6 +217,6 @@
<value>Stream does not support writing.</value>
</data>
<data name="EncryptionNotSupported" xml:space="preserve">
<value>You specified a password in the connection string, but the native SQLite library you're using doesn't support encryption.</value>
<value>You specified a password in the connection string, but the native SQLite library '{libraryName}' doesn't support encryption.</value>
</data>
</root>
4 changes: 2 additions & 2 deletions src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ public override void Open()
{
if (!string.IsNullOrEmpty(ConnectionOptions.Password))
{
if (SQLitePCLExtensions.EncryptionSupported() == false)
if (SQLitePCLExtensions.EncryptionSupported(out var libraryName) == false)
{
throw new InvalidOperationException(Resources.EncryptionNotSupported);
throw new InvalidOperationException(Resources.EncryptionNotSupported(libraryName));
}

// NB: SQLite doesn't support parameters in PRAGMA statements, so we escape the value using the
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.Data.Sqlite.Tests/SqliteConnectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private void Open_works_when_password_unsupported()

var ex = Assert.Throws<InvalidOperationException>(() => connection.Open());

Assert.Equal(Resources.EncryptionNotSupported, ex.Message);
Assert.Equal(Resources.EncryptionNotSupported(GetNativeLibraryName()), ex.Message);
Assert.False(stateChangeRaised);
Assert.Equal(ConnectionState.Closed, connection.State);
}
Expand Down

0 comments on commit 97a55ec

Please sign in to comment.