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

DeniedCharactersRegex broken in current NuGet build #52

Closed
poke opened this issue Oct 9, 2022 · 5 comments
Closed

DeniedCharactersRegex broken in current NuGet build #52

poke opened this issue Oct 9, 2022 · 5 comments
Labels

Comments

@poke
Copy link
Contributor

poke commented Oct 9, 2022

(tl;dr: You need to release fixes to NuGet)

So, this was a “fun” one. When attempting to use the library from NuGet, DeniedCharactersRegex doesn’t work and the library will always return an empty string, regardless of what you pass as input string.

To reproduce

Simple example, create a new console application and add the dependency:

dotnet new console
dotnet add package Slugify.Core

Edit the Program.cs to contain the following:

using Slugify;

var config = new SlugHelperConfiguration();
config.DeniedCharactersRegex = "[^abc]";

var helper = new SlugHelper(config);
Console.WriteLine($"'{helper.GenerateSlug("abcdef")}'");

Run the project:

PS > dotnet run
''

Analysis

As it turns out, the following code is the problem:

var currentValue = sb.ToString();
sb.Clear();
sb.Append(DeleteCharacters(currentValue, deniedCharactersRegex));

In the released NuGet version, this appears to be compiled to the following:

sb.Clear();
sb.Append(DeleteCharacters(sb.ToString(), deniedCharactersRegex));

Originally, I thought this was some compiler optimization bug where it would inline the ToString() call here. But looking further, I realized that the released NuGet version is actually a bit older and this is actually the real code there:

sb.Clear();
sb.Append(DeleteCharacters(sb.ToString(), deniedCharactersRegex));

Sooo, this was fixed in #22, and apparently that change never made it onto NuGet (along with some of the other fixes that happened last year). So can you publish a new version to NuGet soon? 😁

@ctolkien ctolkien added the bug label Oct 10, 2022
@ctolkien
Copy link
Owner

Related:
#27

@poke
Copy link
Contributor Author

poke commented Oct 10, 2022

So you don’t want to do a NuGet release manually and keep all these bugs in until you can automate the process? 😅

@ctolkien
Copy link
Owner

Hey @poke - finally got around to this... didn't actually mean for it to run... but here we are.. v4 just went out!

@ctolkien
Copy link
Owner

Spoke to soon, sent this to the local github nuget package repo.. not nuget for real

@ctolkien ctolkien reopened this Jan 17, 2023
@ctolkien
Copy link
Owner

Fixed for reals now.!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants