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

Microsoft.Data.Sqlite: Review resources #22480

Merged
1 commit merged into from
Sep 10, 2020
Merged
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 @@ -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