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

Conflict with Microsoft.IdentityModel.Tokens.CollectionUtilities.IsNullOrEmpty extension #1722

Closed
CodeBlanch opened this issue Oct 12, 2021 · 12 comments · Fixed by #2699
Closed
Assignees
Labels
Breaking change Bug Product is not functioning as expected Customer reported Indicates issue was opened by customer P2 High, but not urgent. Needs to be addressed within the next couple of sprints Question User has asked a question
Milestone

Comments

@CodeBlanch
Copy link

This Microsoft.IdentityModel.Tokens.CollectionUtilities.IsNullOrEmpty extension introduced in the latest version broke one of the codebases I work on because there is a similar extension already present. It was easy enough to fully quality things where we had issues but I thought I would raise the question here: Should CollectionUtilities be internal to Microsoft.IdentityModel.Tokens?

@mafurman mafurman added Bug Product is not functioning as expected Customer reported Indicates issue was opened by customer Question User has asked a question labels Oct 13, 2021
@brentschmaltz
Copy link
Member

@CodeBlanch rats.
Did you use the same namespace prefix M.IM.Tokens?

It should have been internal, that is a mistake.
It would now be breaking for us to remove it, can you live with it?

@CodeBlanch
Copy link
Author

@brentschmaltz Not exactly. Let's say my extension is:

namespace Company.Extensions
{
    public static class EnumerableExtensions
    {
          public static bool IsNullOrEmpty<T>(this IEnumerable<T> enumerable) { ... }
    }
}

I had some code like...

using Microsoft.IdentityModel.Tokens;
using Company.Extensions;

public class SomeClass
{
    public TokenValidationParameters BuildValidationParameters(ValidationOptions options)
    {
        return new TokenValidationParameters
	{
		ValidAudiences = options.ValidAudiences.IsNullOrEmpty()
			? options.DefaultValidAudiences
			: options.ValidAudiences;
	};
    }
}

In that case, because both IsNullOrEmpty extensions are in scope, the compiler doesn't know which one to pick and it complains.

Fix is just to qualify it like...

using Microsoft.IdentityModel.Tokens;
using Company.Extensions;

public class SomeClass
{
    public TokenValidationParameters BuildValidationParameters(ValidationOptions options)
    {
        return new TokenValidationParameters
	{
		ValidAudiences = EnumerableExtensions.IsNullOrEmpty(options.ValidAudiences)
			? options.DefaultValidAudiences
			: options.ValidAudiences;
	};
    }
}

Easy enough workaround, no big deal to keep it like that.

@brockallen
Copy link

It should have been internal, that is a mistake.

Too bad this wasn't addressed when you could. We're now seeing conflicts as well. Why can't you make this internal?

@aaron-meyers
Copy link

@brentschmaltz can you please reconsider leaving this public? We just wasted a couple days hunting down build issues in Power BI which ended up being related to accidental use of this extension method. Your assembly really should not be exposing an extremely generic and easily misused extension like this. Because of the signature, this extension method even shows up on standard strings where it really should not be used in place of the static string.IsNullOrEmpty method.

Components can introduce breaking changes with a major version bump. I don't think leaving this public is the right tradeoff - better to rip off the band-aid and prevent future misuse of this extremely broad extension method.

@brentschmaltz brentschmaltz reopened this May 24, 2023
@brentschmaltz
Copy link
Member

@aaron-meyers i reopened so we can reconsider.

@Dreamescaper
Copy link

Personally I've hoped it would be "internalized" for v7 :(

@brentschmaltz
Copy link
Member

@brockallen i agree, would have been nice to fix this before our 7 release.
We can't get it all done, our focus in 7 was on enabling AOT and improving perf.

@Kebechet
Copy link

Will this be a part of v8 ?

@jennyf19 jennyf19 added P2 High, but not urgent. Needs to be addressed within the next couple of sprints Breaking change labels Mar 27, 2024
@jmprieur
Copy link
Contributor

jmprieur commented May 1, 2024

Closing as there is an easy workaround (fully qualify conflicting methods), and customers are used to using this convenience method now.
Ideally this should be in the .NET Framework

cc: @eerhardt FYI

@jmprieur jmprieur closed this as completed May 1, 2024
@Dreamescaper
Copy link

Please consider reopening it.
I understand not wanting to fix it now, since it's a breaking change, but would be really nice to have it removed in the next major version.

@Kebechet
Copy link

Kebechet commented May 1, 2024

@jmprieur I agree with @Dreamescaper this extension method is PITA. So please in next major version remove this

and customers are used to using this convenience method now.

No, responsibility of this package is not to provide this type of extension methods. So it simply shouldnt be there because for others(us included) it causes other inconveniences.

@Dreamescaper
Copy link

@brentschmaltz
I can see that the next major version is in preview now (8.0.0-preview1). Is is possible to include this change there?

@pmaytak pmaytak added this to the 8.0.0-preview2 milestone Jul 11, 2024
@pmaytak pmaytak self-assigned this Jul 11, 2024
@pmaytak pmaytak linked a pull request Jul 11, 2024 that will close this issue
abhishekkumams added a commit to Azure/data-api-builder that referenced this issue Nov 27, 2024
…OrEmpty` (#2471)

## Why make this change?

- Closes #2469 
- There is a namespace collision for the `IsNullOrEmpty` method in the
`MsSqlQueryBuilder` class between String and CollectionUtils class.

## What is this change?

- `MsSqlQueryBuilder` class had a check in the `Build` method where it
was using `IsNullOrEmpty` for Strings but it was refrencing
CollectionUtils Class instead
- Removed `Collection.Utilities` class from Cli and renamed it in the
Core project to `EnumerableUtilities` to avoid any future namespace
collision.
- Also updated all the references of `IsNullOrEmpty`

## How was this tested?

- [x] manual tests
- [x] current existing tests

Notes:
Work Around shared here:
AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet#1722

---------

Co-authored-by: Aaron Burtle <aaronburtle@microsoft.com>
Co-authored-by: aaronburtle <93220300+aaronburtle@users.noreply.github.com>
abhishekkumams added a commit to Azure/data-api-builder that referenced this issue Nov 28, 2024
…OrEmpty` (#2471)

## Why make this change?

- Closes #2469 
- There is a namespace collision for the `IsNullOrEmpty` method in the
`MsSqlQueryBuilder` class between String and CollectionUtils class.

## What is this change?

- `MsSqlQueryBuilder` class had a check in the `Build` method where it
was using `IsNullOrEmpty` for Strings but it was refrencing
CollectionUtils Class instead
- Removed `Collection.Utilities` class from Cli and renamed it in the
Core project to `EnumerableUtilities` to avoid any future namespace
collision.
- Also updated all the references of `IsNullOrEmpty`

## How was this tested?

- [x] manual tests
- [x] current existing tests

Notes:
Work Around shared here:
AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet#1722

---------

Co-authored-by: Aaron Burtle <aaronburtle@microsoft.com>
Co-authored-by: aaronburtle <93220300+aaronburtle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change Bug Product is not functioning as expected Customer reported Indicates issue was opened by customer P2 High, but not urgent. Needs to be addressed within the next couple of sprints Question User has asked a question
Projects
None yet
10 participants