Skip to content

Commit

Permalink
bump tcgc and typespec/rest version (#98)
Browse files Browse the repository at this point in the history
* bump tcgc version, bump rest version

* regenerate petstore and todoapp

* align dotnet version in servers

* regen

* remove unnecessary files

* add a script to verify dotnet

* udpate python emitter version

* refresh for python

---------

Co-authored-by: Yuchao Yan <[email protected]>
  • Loading branch information
ArcturusZhang and msyyc authored Jan 24, 2025
1 parent be3876d commit d27edd2
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 132 deletions.
33 changes: 33 additions & 0 deletions eng/scripts/dotnet/Generate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Set-Location (Resolve-Path (Join-Path $PSScriptRoot '..' '..' '..'))

# Make sure everything is up-to-date
npm ci

# Generate
Remove-Item ./petstore/clients/dotnet/src/Generated -Recurse -Force
Push-Location ./petstore/spec
npx --no-install tsp compile . --emit "@typespec/http-client-csharp"
Pop-Location

Remove-Item ./todoApp/clients/dotnet/src/Generated -Recurse -Force
Push-Location ./todoApp/spec
npx --no-install tsp compile . --emit "@typespec/http-client-csharp"
Pop-Location

# Build and install SDK
Push-Location ./petstore/clients/dotnet
dotnet build
Pop-Location

Push-Location ./todoApp/clients/dotnet
dotnet build
Pop-Location

# Build samples
Push-Location ./petstore/samples/dotnet
dotnet build
Pop-Location

Push-Location ./todoApp/samples/dotnet
dotnet build
Pop-Location
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"@azure-tools/typespec-autorest": "^0.50.0",
"@azure-tools/typespec-azure-core": "^0.50.0",
"@azure-tools/typespec-azure-resource-manager": "^0.50.0",
"@azure-tools/typespec-client-generator-core": "^0.50.0",
"@azure-tools/typespec-client-generator-core": "^0.50.2",
"@typespec/compiler": "^0.64.0",
"@typespec/http": "^0.64.0",
"@typespec/http-client-csharp": "^0.1.9-alpha.20250117.1",
"@typespec/http-client-csharp": "^0.1.9-alpha.20250123.2",
"@typespec/http-server-csharp": "0.58.0-alpha.7",
"@typespec/http-server-javascript": "^0.58.0-alpha.7",
"@typespec/http-client-java": "^0.1.9",
"@azure-tools/typespec-ts": "^0.38.1",
"@typespec/http-client-python": "^0.6.5",
"@typespec/http-client-python": "^0.6.8",
"@typespec/json-schema": "^0.64.0",
"@typespec/openapi": "^0.64.0",
"@typespec/openapi3": "^0.64.0",
"@typespec/rest": "^0.64.0",
"@typespec/rest": "^0.64.1",
"@typespec/streams": "^0.64.0",
"@typespec/versioning": "^0.64.0"
}
Expand Down
60 changes: 60 additions & 0 deletions petstore/clients/python/petstore/_model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,34 @@ def __ne__(self, other: typing.Any) -> bool:
return not self.__eq__(other)

def keys(self) -> typing.KeysView[str]:
"""
:returns: a set-like object providing a view on D's keys
:rtype: ~typing.KeysView
"""
return self._data.keys()

def values(self) -> typing.ValuesView[typing.Any]:
"""
:returns: an object providing a view on D's values
:rtype: ~typing.ValuesView
"""
return self._data.values()

def items(self) -> typing.ItemsView[str, typing.Any]:
"""
:returns: set-like object providing a view on D's items
:rtype: ~typing.ItemsView
"""
return self._data.items()

def get(self, key: str, default: typing.Any = None) -> typing.Any:
"""
Get the value for key if key is in the dictionary, else default.
:param str key: The key to look up.
:param any default: The value to return if key is not in the dictionary. Defaults to None
:returns: D[k] if k in D, else d.
:rtype: any
"""
try:
return self[key]
except KeyError:
Expand All @@ -397,17 +416,38 @@ def pop(self, key: str, default: _T) -> _T: ...
def pop(self, key: str, default: typing.Any) -> typing.Any: ...

def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
"""
Removes specified key and return the corresponding value.
:param str key: The key to pop.
:param any default: The value to return if key is not in the dictionary
:returns: The value corresponding to the key.
:rtype: any
:raises KeyError: If key is not found and default is not given.
"""
if default is _UNSET:
return self._data.pop(key)
return self._data.pop(key, default)

def popitem(self) -> typing.Tuple[str, typing.Any]:
"""
Removes and returns some (key, value) pair
:returns: The (key, value) pair.
:rtype: tuple
:raises KeyError: if D is empty.
"""
return self._data.popitem()

def clear(self) -> None:
"""
Remove all items from D.
"""
self._data.clear()

def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
"""
Updates D from mapping/iterable E and F.
:param any args: Either a mapping object or an iterable of key-value pairs.
"""
self._data.update(*args, **kwargs)

@typing.overload
Expand All @@ -417,6 +457,13 @@ def setdefault(self, key: str, default: None = None) -> None: ...
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...

def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
"""
Same as calling D.get(k, d), and setting D[k]=d if k not found
:param str key: The key to look up.
:param any default: The value to set if key is not in the dictionary
:returns: D[k] if k in D, else d.
:rtype: any
"""
if default is _UNSET:
return self._data.setdefault(key)
return self._data.setdefault(key, default)
Expand Down Expand Up @@ -910,6 +957,19 @@ def _failsafe_deserialize(
return None


def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None


class _RestField:
def __init__(
self,
Expand Down
Loading

0 comments on commit d27edd2

Please sign in to comment.