{"id":32258777,"url":"https://github.com/pseudocc/dotnetjs","last_synced_at":"2025-12-12T04:23:21.529Z","repository":{"id":41288089,"uuid":"71432704","full_name":"pseudocc/dotnetjs","owner":"pseudocc","description":".Net Framework support in javascript/typescript.","archived":false,"fork":false,"pushed_at":"2023-12-01T07:09:51.000Z","size":250,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-10T21:23:59.299Z","etag":null,"topics":["gethashcode","javascript","linq","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pseudocc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-10-20T06:36:47.000Z","updated_at":"2023-12-01T07:05:20.000Z","dependencies_parsed_at":"2025-05-06T10:06:48.215Z","dependency_job_id":"7dd831ac-e327-417a-930d-ef821291023f","html_url":"https://github.com/pseudocc/dotnetjs","commit_stats":null,"previous_names":["master76/dotnetjs","main76/dotnetjs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pseudocc/dotnetjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocc%2Fdotnetjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocc%2Fdotnetjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocc%2Fdotnetjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocc%2Fdotnetjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pseudocc","download_url":"https://codeload.github.com/pseudocc/dotnetjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseudocc%2Fdotnetjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280503191,"owners_count":26341693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gethashcode","javascript","linq","typescript"],"created_at":"2025-10-22T19:52:37.347Z","updated_at":"2025-10-22T19:52:39.141Z","avatar_url":"https://github.com/pseudocc.png","language":"TypeScript","readme":"# DotnetJs\n\n.Net Framework support in javascript\n\n## Get DotnetJs\n\n1. Nodejs\n\n    Firstly, run\n\n    ```npm\n    npm install dotnetjs --save\n    ```\n\n    If you are using TypeScript:\n\n    ```typescript\n    import * as DotnetJs from 'dotnetjs';\n    ```\n\n    else just like the others:\n\n    ```javascript\n    var DotnetJs = require('dotnetjs');\n    ```\n\n2. Browser\n\n    Run ```npm install dotnetjs --save```\n\n    or download the files in the dist directory.\n\n    or run ```bower install dotnetjs```\n\n    ```html\n    \u003c!--if debug--\u003e\n    \u003cscript src=\"dotnet.js\"\u003e\u003c/script\u003e\n    \u003c!--if release--\u003e\n    \u003cscript src=\"dotnet.min.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"your.js\"\u003e\u003c/script\u003e\n    ```\n\n    in your .ts file:\n\n    ```typescript\n    /// \u003creference path=\"dotnet.d.ts\" /\u003e\n    ```\n\n## Work with DotnetJs\n\nDotnetJs uses similiar interface as it is in .Net Framework.\n\n### Linq\n\nIf you are about to use complicated Linq Expressions, first make an instance of LinqIntermediate by using LinqStart:\n\n```typescript\nvar expression = DotnetJs.Linq.LinqStart(enumerable);\n```\n\nThe enumerable can be any type that implements IEnumerable, in addition, I implemented it for the Array. Then you can do like the following:\n\n```typescript\nexpression.Where(...).Select(...).ToArray();\n```\n\nOr use:\n\n```typescript\nDotnetJs.Linq.Where(enumerable, ...).Select(...).ToArray();\n```\n\nRemember to use ```ToArray``` or ```ToList``` or ```ToDictionary``` to end the expression(if the result is still IEnumerable). No matter how long your LINQ is, the time complexity is always O(n).\n\n### String Format\n\nThe match case: ```{index[,alignment][:format]}```, with 2 optional parameters (alignment and format).\n\n1. index\n\n    Index indicate the index of the object in the following parameter args[].\n\n2. alignment\n\n    Alignment will do PadLeft or PadRight with spaces. If it is positive then do PadLeft, else do PadRight.\n\n3. format\n\n    With the magic char ':', you can control the format of your toString method. For numbers, the following specifiers ['D', 'E', 'F', 'G', 'N', 'P', 'X'] are implemented, [usage portal](https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx).\n    Now, let's see the following example:\n\n    ```typescript\n    var number = 1.0437E21;\n    var specifier = 'G';\n    console.writeLine(\"   {0,-22} {1:G}\", specifier + \":\", number);\n    // output:   G:                     1.0437e+21\n    \n    class Foo {\n        public bar: number;\n        public toString(format: string) {\n            if (format == null)\n                return this.bar.toString();\n            if (format == '!')\n                return '!' + this.bar;\n            return '?' + this.bar;\n        }\n    }\n\n    var foo = new Foo();\n    foo.bar = 65521;\n\n    console.log(String.Format('test Foo toString: {0:!}, {0:?}, {0,10}', foo));\n    // output: test Foo toString: !65521, ?65521,      65521\n    ```\n\n### Indexer for the collections\n\nAs there isn't a way to implement indexer in typescript you have to call the element of List or IDictionay, by using ```GetValue(index || key)``` and ```SetValue(index || key, value)```, but not ```collection[index || key]```.\n\n### GetHashCode\n\nBoth object, string, boolean or number are supported for the GetHashCode Method, actually for the object, it is more likely to be called as a 'unique id'.\n\nTo get a new hashcode for an object, call the method with parameter 'ture'. But please be careful, this may cause unexpected errors (e.g.: when you are using ```Dictionary```).\n\n### Equals\n\nIf you inherit from TypeScript abstract class ValueType, remember to override the Equals method, else it will compare the result of GetHashCode() to decide whether it equals to the other.\n\n### ContainsKey\n\n```typescript\nvar obj = { name: 'readme' };\n\nconsole.log(obj.ContainsKey('name'));\n// output: true\n```\n\n### TODO\n\nMore extensions. If you have any ideas, please feel free to contact my.\n\n## Test\n\nFirst change directory to tests, then run ```tsc``` to compile the typescript files, then run ```npm link ../``` secondly, to set up the local dependencies, finally run ```node index.js``` to start the test.\n\n## Contributors\n\n[Main76 (legacy account)](https://github.com/main76),\n[pseudocc](https://github.com/pseudocc)  Author\n\n[AsherWang](https://github.com/AsherWang) RegExp suport\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseudocc%2Fdotnetjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpseudocc%2Fdotnetjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseudocc%2Fdotnetjs/lists"}