Skip to content
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
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net461.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public ResourceIdentifier(string resourceId) { }
public static bool operator <=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; }
public static Azure.Core.ResourceIdentifier Parse(string input) { throw null; }
public override string ToString() { throw null; }
public static bool TryParse(string input, out Azure.Core.ResourceIdentifier? result) { throw null; }
public static bool TryParse(string? input, out Azure.Core.ResourceIdentifier? result) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ResourceType : System.IEquatable<Azure.Core.ResourceType>
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net472.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public ResourceIdentifier(string resourceId) { }
public static bool operator <=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; }
public static Azure.Core.ResourceIdentifier Parse(string input) { throw null; }
public override string ToString() { throw null; }
public static bool TryParse(string input, out Azure.Core.ResourceIdentifier? result) { throw null; }
public static bool TryParse(string? input, out Azure.Core.ResourceIdentifier? result) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ResourceType : System.IEquatable<Azure.Core.ResourceType>
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public ResourceIdentifier(string resourceId) { }
public static bool operator <=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; }
public static Azure.Core.ResourceIdentifier Parse(string input) { throw null; }
public override string ToString() { throw null; }
public static bool TryParse(string input, out Azure.Core.ResourceIdentifier? result) { throw null; }
public static bool TryParse(string? input, out Azure.Core.ResourceIdentifier? result) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ResourceType : System.IEquatable<Azure.Core.ResourceType>
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public ResourceIdentifier(string resourceId) { }
public static bool operator <=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; }
public static Azure.Core.ResourceIdentifier Parse(string input) { throw null; }
public override string ToString() { throw null; }
public static bool TryParse(string input, out Azure.Core.ResourceIdentifier? result) { throw null; }
public static bool TryParse(string? input, out Azure.Core.ResourceIdentifier? result) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ResourceType : System.IEquatable<Azure.Core.ResourceType>
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public ResourceIdentifier(string resourceId) { }
public static bool operator <=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; }
public static Azure.Core.ResourceIdentifier Parse(string input) { throw null; }
public override string ToString() { throw null; }
public static bool TryParse(string input, out Azure.Core.ResourceIdentifier? result) { throw null; }
public static bool TryParse(string? input, out Azure.Core.ResourceIdentifier? result) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ResourceType : System.IEquatable<Azure.Core.ResourceType>
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public ResourceIdentifier(string resourceId) { }
public static bool operator <=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; }
public static Azure.Core.ResourceIdentifier Parse(string input) { throw null; }
public override string ToString() { throw null; }
public static bool TryParse(string input, out Azure.Core.ResourceIdentifier? result) { throw null; }
public static bool TryParse(string? input, out Azure.Core.ResourceIdentifier? result) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ResourceType : System.IEquatable<Azure.Core.ResourceType>
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/Azure.Core/src/ResourceIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,13 @@ public static ResourceIdentifier Parse(string input)
/// If the method returns false, result will be null.
/// </param>
/// <returns> True if the parse operation was successful; otherwise, false. </returns>
public static bool TryParse(string input, out ResourceIdentifier? result)
public static bool TryParse(string? input, out ResourceIdentifier? result)
Comment thread
abatishchev marked this conversation as resolved.
Outdated
{
result = null;
if (string.IsNullOrEmpty(input))
return false;

result = new ResourceIdentifier(input);
result = new ResourceIdentifier(input!);
Comment thread
m-nash marked this conversation as resolved.
var error = result.Parse();
if (error is null)
return true;
Expand Down
32 changes: 19 additions & 13 deletions sdk/core/Azure.Core/tests/ResourceIdentifierTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,27 +816,33 @@ public void InvalidTenantID(string id)
Assert.IsFalse(ResourceIdentifier.TryParse(id, out var result));
}

[TestCase(null)]
public void NullInput(string invalidID)
{
Assert.Throws<ArgumentNullException>(() => { _ = new ResourceIdentifier(invalidID).Name; });
Assert.Throws<ArgumentNullException>(() => ResourceIdentifier.Parse(invalidID));
Assert.IsFalse(ResourceIdentifier.TryParse(invalidID, out var result));
}

[TestCase("")]
public void EmptyInput(string invalidID)
{
Assert.Throws<ArgumentException>(() => { _ = new ResourceIdentifier(invalidID).Name; });
Assert.Throws<ArgumentException>(() => ResourceIdentifier.Parse(invalidID));
Assert.IsFalse(ResourceIdentifier.TryParse(invalidID, out var result));
}

[TestCase(" ")]
[TestCase("asdfghj")]
[TestCase("123456")]
[TestCase("!@#$%^&*/")]
[TestCase("/subscriptions/")]
[TestCase("/0c2f6471-1bf0-4dda-aec3-cb9272f09575/myRg/")]
public void InvalidRPIds(string invalidID)
public void InvalidInput(string invalidID)
{
if (invalidID == String.Empty)
{
Assert.Throws<ArgumentException>(() => { _ = new ResourceIdentifier(invalidID).Name; });
Assert.Throws<ArgumentException>(() => ResourceIdentifier.Parse(invalidID));
Assert.IsFalse(ResourceIdentifier.TryParse(invalidID, out var result));
}
else
{
Assert.Throws<FormatException>(() => { _ = new ResourceIdentifier(invalidID).Name; });
Assert.Throws<FormatException>(() => ResourceIdentifier.Parse(invalidID));
Assert.IsFalse(ResourceIdentifier.TryParse(invalidID, out var result));
}
Assert.Throws<FormatException>(() => { _ = new ResourceIdentifier(invalidID).Name; });
Assert.Throws<FormatException>(() => ResourceIdentifier.Parse(invalidID));
Assert.IsFalse(ResourceIdentifier.TryParse(invalidID, out var result));
}

[TestCase(TrackedResourceId)]
Expand Down