| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
.NET Framework compatibility layer for PowerCSharp - Essential utilities and extensions for legacy .NET Framework applications with System.Web dependencies. This package provides a seamless migration path from .NET Framework to modern .NET while maintaining compatibility with existing PowerCSharp interfaces.
⚠️ .NET Framework Exclusive: This package is specifically designed for .NET Framework applications (4.6.2, 4.7.2, 4.8) and includes System.Web dependencies. For modern .NET applications, use other PowerCSharp packages.
PowerCSharp.Compatibility bridges the gap between modern PowerCSharp utilities and legacy .NET Framework applications, providing:
dotnet add package PowerCSharp.CompatibilityPackage Manager Console:
Install-Package PowerCSharp.CompatibilityEnhanced string manipulation with System.Web.HttpUtility integration.
using PowerCSharp.Compatibility.Extensions;
// URL query parameter manipulation
string baseUrl = "https://example.com/search";
var parameters = new Dictionary<string, string>
{
["q"] = "csharp tutorial",
["page"] = "1",
["lang"] = "en"
};
string fullUrl = baseUrl.AppendQueryParameters(parameters);
// Result: "https://example.com/search?q=csharp%20tutorial&page=1&lang=en"Safely bridge async operations to synchronous contexts without deadlocks.
using PowerCSharp.Compatibility.Helpers;
// In MVC filters or other synchronous contexts
public class MyMvcFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Safely call async methods from sync context
var result = AsyncHelper.RunSync(() => GetUserDataAsync(filterContext.HttpContext.User));
filterContext.ActionParameters["userData"] = result;
base.OnActionExecuting(filterContext);
}
private async Task<UserData> GetUserDataAsync(IPrincipal user)
{
// Your async operation here
return await userService.GetUserAsync(user.Identity.Name);
}
}Framework-compatible validation helpers with custom attributes.
using PowerCSharp.Compatibility.Utilities;
using PowerCSharp.Compatibility.Utilities.Attributes;
// Method parameter validation
public void ProcessData([ValidatedNotNull] string input, int count)
{
if (string.IsNullOrEmpty(input))
throw new ArgumentException("Input cannot be null or empty");
// Additional validation logic
}
// Validation helper usage
bool isValid = ValidationHelper.IsValidEmail("user@example.com");
bool isNumeric = ValidationHelper.IsNumeric("12345");PowerCSharp.Compatibility/
├── Extensions/
│ └── StringExtensions.cs # System.Web URL utilities
├── Helpers/
│ └── AsyncHelper.cs # Async-to-sync bridging
└── Utilities/
├── Attributes/
│ └── ValidatedNotNullAttribute.cs # Validation attributes
└── ValidationHelper.cs # Framework-compatible validation
PowerCSharp.Compatibility provides a smooth migration path:
// Phase 1: .NET Framework with PowerCSharp.Compatibility
using PowerCSharp.Compatibility.Extensions;
string url = oldUrl.AppendQueryParameters(params);
// Phase 3: Modern .NET with PowerCSharp.Extensions
using PowerCSharp.Extensions;
Uri uri = new Uri(oldUrl).AddParameter("key", "value");// .NET Framework application
using PowerCSharp.Compatibility.Extensions; // For System.Web utilities
using PowerCSharp.Compatibility.Helpers; // For async bridging
using PowerCSharp.Core; // Shared interfaces| Framework | Version | Support | Notes |
|---|---|---|---|
| .NET Framework | 4.6.2+ | ✅ Full | Minimum supported version |
| .NET Framework | 4.7.2 | ✅ Full | Recommended version |
| .NET Framework | 4.8 | ✅ Full | Latest Framework version |
| .NET Core | Any | ❌ No | Use PowerCSharp.Extensions instead |
| .NET 5+ | Any | ❌ No | Use PowerCSharp.Extensions instead |
| .NET Standard | Any | ❌ No | Use PowerCSharp.Extensions instead |
PowerCSharp.Compatibility includes comprehensive unit tests for all target frameworks:
# Test all frameworks
dotnet test src/PowerCSharp.Compatibility.Tests
# Test specific framework
dotnet test src/PowerCSharp.Compatibility.Tests --framework net48using PowerCSharp.Compatibility.Extensions;
using PowerCSharp.Compatibility.Helpers;
public partial class SearchPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Build search URL with parameters
var searchParams = new Dictionary<string, string>
{
["q"] = Request.QueryString["q"] ?? "",
["category"] = ddlCategories.SelectedValue,
["page"] = "1"
};
string searchUrl = "~/Search.aspx".AppendQueryParameters(searchParams);
Response.Redirect(searchUrl);
}
}
protected async void btnSearch_Click(object sender, EventArgs e)
{
// In Web Forms, you might need to call async from sync
var results = AsyncHelper.RunSync(() => SearchService.SearchAsync(txtSearch.Text));
gvResults.DataSource = results;
gvResults.DataBind();
}
}using PowerCSharp.Compatibility.Helpers;
using System.Web.Mvc;
public class UserAuthorizationFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var user = filterContext.HttpContext.User;
// Safely call async authorization service
var isAuthorized = AsyncHelper.RunSync(() =>
AuthorizationService.IsUserAuthorizedAsync(user.Identity.Name));
if (!isAuthorized)
{
filterContext.Result = new HttpNotFoundResult();
return;
}
base.OnActionExecuting(filterContext);
}
}using PowerCSharp.Compatibility.Extensions;
using PowerCSharp.Compatibility.Utilities;
public class LegacyApiService
{
public string BuildApiUrl(string baseUrl, object parameters)
{
var dict = new Dictionary<string, string>();
// Convert object to dictionary
foreach (var prop in parameters.GetType().GetProperties())
{
var value = prop.GetValue(parameters)?.ToString() ?? "";
if (!string.IsNullOrEmpty(value))
{
dict[prop.Name] = value;
}
}
return baseUrl.AppendQueryParameters(dict);
}
public bool ValidateRequest(string request)
{
return !string.IsNullOrEmpty(request) &&
ValidationHelper.IsNumeric(request.Substring(0, 4));
}
}Contributions are welcome! Please read our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
PowerCSharp.Compatibility - Keeping .NET Framework applications powerful and modern! 🚀
| Back | FazBrowse Home | New Git URL |